Last active
May 20, 2024 12:38
-
-
Save adamcameron/7bbe56854bd9b0dbb14524c2be49fe16 to your computer and use it in GitHub Desktop.
Demonstrates integer types in CFML
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 {} |
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 { | |
public function takesInteger(required integer i) { | |
return i | |
} | |
public integer function returnsInteger(required i) { | |
return i | |
} | |
} |
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 {} |
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> | |
o = new C() | |
testCases = [ | |
{label="42", value=42}, | |
{label="4.2", value=4.2}, | |
{label="new integer()", value=new integer()} | |
] | |
testCases.each((testCase) => { | |
writeOutput("<h2>Testing with #testCase.label#</h2>") | |
try { | |
result = o.takesInteger(testCase.value) | |
writeOutput("o.takesInteger(#testCase.label#) returned #serializeJson(result)#<br>") | |
}catch (any e) { | |
writeDump([ | |
message = e.message, | |
detail = e.detail | |
]) | |
} | |
try { | |
result = o.returnsInteger(testCase.value) | |
writeOutput("o.returnsInteger(#testCase.label#) returned #serializeJson(result)#<br>") | |
}catch (any e) { | |
writeDump([ | |
message = e.message, | |
detail = e.detail | |
]) | |
} | |
writeOutput("<hr>") | |
}) | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment