Last active
October 29, 2025 23:46
-
-
Save JamoCA/de3810f7b3248e161b2e9a2cbe161376 to your computer and use it in GitHub Desktop.
Integer increment test for Adobe ColdFusion, Lucee and BoxLang.
This file contains hidden or 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> | |
| // How do CFML platforms increase an integer? Is datatype/class faithfully retained? | |
| // 2025-10-24 (Updated 2025-10-29 with more tests) | |
| // by James Moberg - www.myCFML.com | |
| // NOTE: Test this on TryCF.com (CFFiddle doesn't allow the use of getMetaData.) | |
| test = [ | |
| "platform": (server.keyexists("boxlang")) ? "BoxLang" : server.coldfusion.productname, | |
| x: javacast("int", 0) | |
| ]; | |
| test["type_original"] = getMetaData(test.x).getCanonicalName(); | |
| // +1 | |
| test.x += 1; | |
| test["type_plusOne"] = getMetaData(test.x).getCanonicalName(); | |
| // reset + ++1 | |
| test.x = javacast("int", 0); | |
| test.x ++; | |
| test["type_plusPlus"] = getMetaData(test.x).getCanonicalName(); | |
| // reset + cast+cast | |
| test.x = javacast("int", 0); | |
| test.x += javacast("int", 1); | |
| test["type_plusCast"] = getMetaData(test.x).getCanonicalName(); | |
| // reset + incrementValue | |
| test.x = javacast("int", 0); | |
| test.x = incrementValue(test.x); | |
| test["type_incrementValue"] = getMetaData(test.x).getCanonicalName(); | |
| // reset + java.lang.Integer | |
| try { | |
| test.x = javacast("int", 0); | |
| test.x = createObject("java", "java.lang.Integer").valueOf( test.x + 1 ); | |
| test["type_java.lang.Integer"] = getMetaData(test.x).getCanonicalName(); | |
| } catch (any e){ | |
| writedump(var="java.lang.Integer Fail: #e.message#", type="text"); | |
| } | |
| // reset + java.util.concurrent.atomic.AtomicInteger | |
| try { | |
| text.x = createObject( "java", "java.util.concurrent.atomic.AtomicInteger" ) | |
| .init( javaCast( "int", 1 ) ) | |
| ; | |
| test.x.incrementValue(); | |
| test["type_AtomicInteger"] = getMetaData(test.x).getCanonicalName(); | |
| } catch (any e){ | |
| writedump(var="AtomicInteger Fail: #e.message#", type="text"); | |
| } | |
| writedump(var=test, label="results"); | |
| </cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment