Created
July 14, 2010 02:04
-
-
Save virtix/474902 to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="UTF-8"?> | |
<projectDescription> | |
<name>adam-c-gists</name> | |
<comment></comment> | |
<projects> | |
</projects> | |
<buildSpec> | |
</buildSpec> | |
<natures> | |
<nature>org.cfeclipse.cfml.CFENature</nature> | |
</natures> | |
</projectDescription> |
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
<cfcomponent extends="mxunit.framework.TestCase" output="false"> | |
<cfset iterations=500> | |
<cffunction name="test1SeparateArgs" dataprovider="iterations" access="public" output="false" returntype="void"> | |
<cfargument name="index"> | |
<cfscript> | |
var oMock = mock(); | |
var bResult = false; | |
var dteArgDate = now(); | |
oMock.testMethod( strArg1 = "foo", dateArg = dteArgDate).returns(true); | |
bResult = oMock.testMethod( strArg1 = "foo", dateArg = dteArgDate ); | |
assertTrue(isBoolean(bResult), "Iteration Num: #index# :: Result should be boolean, whereas it's a #getMetadata(bResult).name#"); | |
assertTrue(bResult, "Iteration Num: #index# :: Result should be true"); | |
</cfscript> | |
</cffunction> | |
<cffunction name="test2ArgCollection" dataprovider="iterations" access="public" output="false" returntype="void"> | |
<cfargument name="index"> | |
<cfscript> | |
var oMock = mock(); | |
var bResult = true; | |
var dteArgDate = now(); | |
var stuArgs = structNew(); | |
stuArgs.strArg1 = "foo"; | |
stuArgs.dateArg = dteArgDate; | |
oMock.testMethod ( argumentCollection = stuArgs).returns(true); | |
bResult = oMock.testMethod( argumentCollection = stuArgs ); | |
assertTrue(isBoolean(bResult), "Iteration Num: #index# :: Result should be boolean, whereas it's a #getMetadata(bResult).name#"); | |
assertTrue(bResult, "Iteration Num: #index# :: Result should be true"); | |
</cfscript> | |
</cffunction> | |
</cfcomponent> |
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
<cfcomponent extends="mxunit.framework.TestCase" output="false"> | |
<cfset iterations=1> | |
<cffunction name="testWithIndividualWildcards" dataprovider="iterations" access="public" output="false" returntype="void"> | |
<cfargument name="index"> | |
<cfscript> | |
var oMock = mock(); | |
var bResult = false; | |
var dteArgDate = now(); | |
oMock.testMethod( strArg1='{string}', dateArg='{date}').returns(true); | |
bResult = oMock.testMethod( strArg1 = "foo", dateArg = dteArgDate ); | |
assertTrue(isBoolean(bResult), "Iteration Num: #index# :: Result should be boolean, whereas it's a #getMetadata(bResult).name#"); | |
assertTrue(bResult, "Iteration Num: #index# :: Result should be true"); | |
</cfscript> | |
</cffunction> | |
<cffunction name="testWithSingleWildcard" dataprovider="iterations" access="public" output="false" returntype="void"> | |
<cfargument name="index"> | |
<cfscript> | |
var oMock = mock(); | |
var bResult = false; | |
var dteArgDate = now(); | |
oMock.testMethod( '{+}').returns(true); | |
bResult = oMock.testMethod( strArg1 = "foo", dateArg = dteArgDate ); | |
assertTrue(isBoolean(bResult), "Iteration Num: #index# :: Result should be boolean, whereas it's a #getMetadata(bResult).name#"); | |
assertTrue(bResult, "Iteration Num: #index# :: Result should be true"); | |
</cfscript> | |
</cffunction> | |
</cfcomponent> |
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
<!--- C.cfc ---> | |
<cfcomponent> | |
<cffunction name="onMissingMethod"> | |
<cfargument name="missingMethodName" type="string" required="true"> | |
<cfargument name="missingMethodArguments" type="struct" required="true"> | |
<cfset var stResult = structNew()> | |
<cfset stResult.id = argId(arguments.missingMethodArguments)> | |
<cfset stResult.type = arguments.missingMethodArguments.getClass().getName()> | |
<cfreturn stResult> | |
</cffunction> | |
<!--- lifted from MXUnit code ---> | |
<cfscript> | |
function argId(args){ | |
var caseInsensitiveArgs = uCase(args.toString()); | |
return caseInsensitiveArgs.hashCode(); | |
} | |
</cfscript> | |
</cfcomponent> |
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> | |
component extends="mxunit.framework.TestCase"{ | |
/** | |
* @dataprovider 50000 | |
**/ | |
function testThis(numeric index){ | |
var d = now(); | |
var stArgs = { strArg1 = "string", dateArg = d }; | |
var o = createObject("component", "C"); | |
var stResult = {}; | |
var stResult.ArgCollection.1 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.2 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.valid = stResult.ArgCollection.1.id eq stResult.ArgCollection.2.id; | |
assert(stResult.ArgCollection.valid); | |
stResult.NamedPairs.1 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.2 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.valid = stResult.NamedPairs.1.id eq stResult.NamedPairs.2.id; // about 50% of the time this is "NO" | |
// control | |
assert(stResult.NamedPairs.valid); | |
stResult.struct.1.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.1.type = stArgs.getClass().getName(); | |
stResult.struct.2.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.2.type = stArgs.getClass().getName(); | |
stResult.struct.valid = stResult.struct.1.id eq stResult.struct.2.id; | |
assert( stResult.struct.valid ); | |
// uncommenting at your own risk | |
// debug( stResult ); | |
} | |
} | |
</cfscript> |
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> | |
component extends="mxunit.framework.TestCase"{ | |
iterations = 5000; | |
/** | |
* @dataprovider iterations | |
**/ | |
function testThis(numeric index){ | |
var d = now(); | |
var stArgs = { strArg1 = "string", dateArg = d }; | |
var o = createObject("component", "C"); | |
var stResult = {}; | |
var stResult.ArgCollection.1 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.2 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.valid = stResult.ArgCollection.1.id eq stResult.ArgCollection.2.id; | |
assert(stResult.ArgCollection.valid); | |
stResult.NamedPairs.1 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.2 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.valid = stResult.NamedPairs.1.id eq stResult.NamedPairs.2.id; // about 50% of the time this is "NO" | |
// control | |
assert(stResult.NamedPairs.valid); | |
stResult.struct.1.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.1.type = stArgs.getClass().getName(); | |
stResult.struct.2.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.2.type = stArgs.getClass().getName(); | |
stResult.struct.valid = stResult.struct.1.id eq stResult.struct.2.id; | |
assert( stResult.struct.valid ); | |
// uncommenting at your own risk | |
// debug( stResult ); | |
} | |
} | |
</cfscript> |
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> | |
component extends="mxunit.framework.TestCase"{ | |
iterations = 50000; | |
/** | |
* @dataprovider iterations | |
**/ | |
function testThis(numeric index){ | |
var d = now(); | |
var stArgs = { strArg1 = "string", dateArg = d }; | |
var o = createObject("component", "C"); | |
var stResult = {}; | |
var stResult.ArgCollection.1 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.2 = o.f1(argumentCollection=stArgs); | |
stResult.ArgCollection.valid = stResult.ArgCollection.1.id eq stResult.ArgCollection.2.id; | |
assert(stResult.ArgCollection.valid); | |
stResult.NamedPairs.1 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.2 = o.f1(strArg1="string", dateArg=d); | |
stResult.NamedPairs.valid = stResult.NamedPairs.1.id eq stResult.NamedPairs.2.id; // about 50% of the time this is "NO" | |
// control | |
assert(stResult.NamedPairs.valid); | |
stResult.struct.1.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.1.type = stArgs.getClass().getName(); | |
stResult.struct.2.id = uCase(stArgs.toString()).hashCode(); | |
stResult.struct.2.type = stArgs.getClass().getName(); | |
stResult.struct.valid = stResult.struct.1.id eq stResult.struct.2.id; | |
assert( stResult.struct.valid ); | |
// uncommenting at your own risk | |
// debug( stResult ); | |
} | |
} | |
</cfscript> |
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> | |
component extends="mxunit.framework.TestCase"{ | |
expectedString = '{1={1},a={baz},BAR={foo},foo={bar},z={321654}}'; | |
iterations = 50000; | |
/** | |
* @dataprovider iterations | |
*/ | |
function $toStringAStructManyTimes(numeric index){ | |
var s = { 'foo'='bar',bar='foo', 1=1,'z'=321654, 'a'='baz' }; | |
//debug(expectedString); | |
//debug(s.toString()); | |
assertEquals( expectedString, s.toString() , "At iteration #index#"); | |
} | |
function compareArgumentCollectionAndStruct(){ | |
var argCol = createObject("java","coldfusion.runtime.ArgumentCollection"); | |
var structCol = createObject("java","coldfusion.runtime.Struct"); | |
dump(argCol); | |
dump(structCol); | |
//Both are coldfusion.util.CaseInsensitiveMap | |
} | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment