Created
October 5, 2012 12:26
-
-
Save adamcameron/3839563 to your computer and use it in GitHub Desktop.
This demonstrates a bug in CF9+'s implementation of argumentCollections, as well as some weirdness with structCount()
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 baseline(){ | |
var localData = {}; | |
localData.copiedBefore = structCopy(arguments); | |
dummyTest(argumentcollection=arguments); | |
localData.copiedAfter = structCopy(arguments); | |
localData.copiedBefore.d = 4; | |
localData.copiedAfter.d = 4; | |
outputIt(localData); | |
} | |
function withoutDummyTest(){ | |
var localData = {}; | |
localData.copiedBefore =duplicate(arguments); | |
//dummyTest(argumentcollection=arguments); | |
localData.copiedAfter = duplicate(arguments); | |
localData.copiedBefore.d = 4; | |
localData.copiedAfter.d = 4; | |
outputIt(localData); | |
} | |
function withDummyTestSeparateArgs(){ | |
var localData = {}; | |
localData.copiedBefore =structCopy(arguments); | |
dummyTest(a=arguments.a, b=arguments.b, c=arguments.c); | |
localData.copiedAfter = structCopy(arguments); | |
localData.copiedBefore.d = 4; | |
localData.copiedAfter.d = 4; | |
outputIt(localData); | |
} | |
function dummyTest(){ | |
} | |
function outputIt(struct){ | |
var keys = structKeyList(struct.copiedAfter); | |
var count = structCount(struct.copiedAfter); | |
var javaToString = struct.copiedAfter.toString(); | |
var json = serializeJson(struct.copiedAfter); | |
var correctCount = count eq 4; | |
writeOutput("inner args:<br />"); | |
writeOutput("struct.copiedBefore.d = #struct.copiedBefore.d#<br />"); | |
dump(var=struct.copiedBefore, label="struct.copiedBefore"); | |
writeOutput("struct.copiedAfter.d = #struct.copiedAfter.d#<br />"); | |
dump(var=struct.copiedAfter, label="struct.copiedAfter"); | |
writeOutput("structCount is 4: #correctCount#<br />structCount(): #count#<br />structKeyList(): #keys#<br />toString(): #javaToString#<br />serializeJson(): #json#<br />"); | |
} | |
writeOutput("<h3>baseline</h3>"); | |
baseline(a="1",b="2",c="3"); | |
writeOutput("<hr />"); | |
writeOutput("<h3>withoutDummyTest</h3>"); | |
withoutDummyTest(a="1",b="2",c="3"); | |
writeOutput("<hr />"); | |
writeOutput("<h3>withDummyTestSeparateArgs</h3>"); | |
withDummyTestSeparateArgs(a="1",b="2",c="3"); | |
writeOutput("<hr />"); | |
</cfscript> | |
<cffunction name="dump"> | |
<cfdump var="#arguments.var#" label="#arguments.label#"> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment