This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
request.testBox.debug("in pseudo constructor") | |
static { | |
request.testBox.debug("in static constructor") | |
} | |
function init() { | |
request.testBox.debug("in constructor") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Lifecycle function tests" do | |
test_array = [] | |
before(:all) do | |
test_array.push "main block before :all handler" | |
end | |
before(:each) do # or just before with no param | |
test_array.push "main block before :each handler" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function run() { | |
describe("email address tests", () => { | |
tests = [ | |
{label="local too long (fails on CF)", expectation=false, address="#repeatString('x', 65)#@example.com"}, | |
{label="domain too long (fails on CF)", expectation=false, address="x@#repeatString('x', 255)#.com"}, | |
{label="embedded % should be fine (fails on both)", expectation=false, address="first%second@example.com"}, | |
{label="domain format, length and overall length max (both pass)", expectation=true, address="x@x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF.x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF.x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF.x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF-x2345678.com"}, | |
{label="domain label length bad (first one 64 chars; max is 63) (fails on both)", expectation=false, address="x@XX23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF-x23456789ABCDEF.x23456789ABCDEF-x23456789ABCD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
uuid = replace(createUuid(), "-", "", "ALL"); | |
result64 = baseMToBaseN(uuid, "HEX", "BASE62"); | |
result36 = baseMToBaseN(uuid, "HEX", "BASE36"); | |
uuidAgain = baseMToBaseN(result64, "BASE62", "HEX"); | |
writeDump([uuid, result64, result64.len(), uuidAgain, result36, result36.len()]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
include "m.cfm"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test/unit/services/SecurityFilterService | |
describe("Tests for SecurityFilterService", () => { | |
describe("Tests for isAuthorised", () => { | |
it("will reject a user that is not authorised to access the resource", () => { | |
service = new SecurityFilterSerivce() // might need mocked dependencies | |
result = service.isAuthorised("juniorUser", "/email/approve-copy", "patch") | |
expect result.toBeFalse() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// implementation | |
void function describe(required string label, required function testGroup) { | |
try { | |
writeOutput("#label#<br>") | |
testGroup() | |
} catch (any e) { | |
writeOutput("Error: #e.message#<br>") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function run() { | |
describe("some tests", () => { | |
it("a passing test", () => { | |
expect(true).toBe(true) | |
}) | |
it("a failing test", () => { | |
expect(true).toBe(false) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.tinyTest {background-color: black; color:white; font-family:monospace} | |
.tinyTest div {margin-left: 1em} | |
.tinyTest .pass {color:green;} | |
.tinyTest .fail {color:red;} | |
.tinyTest .error {background-color:red; color:black} | |
</style> | |
<cfscript> | |
tinyTest = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function haystackContainsNeedle($haystack, $needle) { | |
$intersection = array_intersect_assoc($haystack, $needle); | |
return $intersection == $needle ? 'true' : 'false'; | |
} | |
$haystack = [ | |
"firstName" => "Adam", | |
"lastName" => "Cameron", |