Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Last active November 1, 2022 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcameron/58ecaa2fb7ab9b1e04679eee2b91bd1a to your computer and use it in GitHub Desktop.
Save adamcameron/58ecaa2fb7ab9b1e04679eee2b91bd1a to your computer and use it in GitHub Desktop.
<cfscript>
function run() {
describe("Comparing behaviour of isObject across CF and Lucee", () => {
describe("Tests using isObject", () => {
describe("Tests when argument is scoped", () => {
var isObjectChecker = (component object) => isObject(arguments.object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isObjectChecker(o)).toBeTrue()
})
it("should throw an exception if the argument is not defined (THIS FAILS ON LUCEE)", () => {
expect(() => {
isObjectChecker()
}).toThrow()
})
})
describe("Analogous testing without explicit scoping", () => {
var isObjectCheckerWithoutExplicitScope = (component object) => isObject(object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isObjectCheckerWithoutExplicitScope(o)).toBeTrue()
})
it("should throw an exception if the argument is not defined (THIS PASSES ON LUCEE, WHICH IS INCONGRUOUS WITH EQUIVALENT SCOPED TEST)", () => {
expect(() => {
isObjectCheckerWithoutExplicitScope()
}).toThrow()
})
})
})
describe("Analogous testing with isValid", () => {
describe("Tests when argument is scoped", () => {
var isValidComponentChecker = (component object) => isValid("component", arguments.object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isValidComponentChecker(o)).toBeTrue()
})
it("should throw an exception if the argument is not defined (THIS FAILS ON LUCEE)", () => {
expect(() => {
isValidComponentChecker()
}).toThrow()
})
})
describe("Analogous testing without explicit scoping", () => {
var isValidComponentCheckerWithoutExplicitScope = (component object) => isValid("component", object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isValidComponentCheckerWithoutExplicitScope(o)).toBeTrue()
})
it("should throw an exception if the argument is not defined (THIS PASSES ON LUCEE, WHICH IS INCONGRUOUS WITH EQUIVALENT SCOPED TEST)", () => {
expect(() => {
isValidComponentCheckerWithoutExplicitScope()
}).toThrow()
})
})
})
describe("Analogous testing with isNull", () => {
describe("Tests when argument is scoped", () => {
var isNullChecker = (component object) => isNull(arguments.object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isNullChecker(o)).toBeFalse()
})
it("should not throw an exception if the argument is not defined", () => {
expect(() => {
isNullChecker()
}).notToThrow()
})
})
describe("Analogous testing with isNull without explicit scoping", () => {
var isNullCheckerWithoutExplicitScope = (component object) => isNull(object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isNullCheckerWithoutExplicitScope(o)).toBeFalse()
})
it("should not throw an exception if the argument is not defined", () => {
expect(() => {
isNullCheckerWithoutExplicitScope()
}).notToThrow()
})
})
})
})
}
tinyTest.runTests()
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment