Permalink
Browse files

ColdFusion MX 7 syntax fixes

  • Loading branch information...
1 parent f03eb60 commit 7e3ab2fd56075c2514cfbefbc51f9839c9b35cac @bittersweetryan bittersweetryan committed Jan 14, 2012
Showing with 54 additions and 13 deletions.
  1. +3 −3 framework/decorators/OrderedTestDecorator.cfc
  2. +38 −8 tests/utils/TestBubbleSort.cfc
  3. +13 −2 utils/BubbleSort.cfc
@@ -8,11 +8,11 @@
var tests = [];
var test = "";
var BubbleSort = createObject("Component","mxunit.utils.BubbleSort");
- var sortedTests = [];
- var returnArray = [];
+ var sortedTests = arrayNew(1);
+ var returnArray = arrayNew(1);
for(i = 1; i LTE arrayLen(methods); i++){
- test = {};
+ test = structNew();
test.order = getAnnotation(methods[i],"order");
test.name = methods[i];
@@ -7,18 +7,48 @@
<cffunction name="TestSortArrayOfStructsNumeric" returntype="void" access="public" output="true" hint="" >
<cfscript>
- var myStruct1 = {value="apple",order="4"};
- var myStruct2 = {value="banana",order="6"};
- var myStruct3 = {value="grape",order="12"};
- var myStruct4 = {value="orange",order="35"};
- var myStruct5 = {value="pear",order="21"};
- var myStruct6 = {value="mango",order="5"};
+ var myStruct1 = structNew();
+ myStruct1.value = "apple";
+ myStruct1.order="4";
- var myArray = [myStruct1,myStruct2,myStruct3,myStruct4,myStruct5,myStruct6];
+ var myStruct2 = structNew();
+ myStruct2.value="banana";
+ myStruct2.order="6";
+
+ var myStruct3 = structNew();
+ myStruct3.value="grape";
+ myStruct3.order="12";
+
+ var myStruct4 = structNew();
+ myStruct4.value="orange";
+ myStruct4.order="35";
+
+ var myStruct5 = structNew();
+ myStruct5.value="pear";
+ myStruct5.order="21";
+
+ var myStruct6 = structNew();
+ myStruct6.value="mango";
+ myStruct6.order="5";
+
+ var myArray = arrayNew(1);
+
+ myArray[1] = myStruct1;
+ myArray[2] = myStruct2;
+ myArray[3] = myStruct3;
+ myArray[4] = myStruct4;
+ myArray[5] = myStruct5;
+ myArray[6] = myStruct6;
var actual = BubbleSort.SortArrayOfStructs(myArray,"order",true);
- var expected = [myStruct1,myStruct6,myStruct2,myStruct3,myStruct5,myStruct4];
+ var expected = arrayNew(1);
+ expected[1] = myStruct1;
+ expected[2] = myStruct6;
+ expected[3] = myStruct2;
+ expected[4] = myStruct3;
+ expected[5] = myStruct5;
+ expected[6] = myStruct4;
assertEquals(actual,expected);
</cfscript>
View
@@ -19,8 +19,19 @@
for(x = 1; x lte len - 1; x = x + 1){
if(isNumber){
- value1 = (isNumeric(theArray[x + 1][theKey])) ? lsParseNumber(theArray[x + 1][theKey]) : 9999;
- value2 = (isNumeric(theArray[x][theKey])) ? lsParseNumber(theArray[x][theKey]) : 9999;
+ if(isNumeric(theArray[x + 1][theKey])){
+ value1 = lsParseNumber(theArray[x + 1][theKey]);
+ }
+ else{
+ value1 = 9999;
+ }
+
+ if(isNumeric(theArray[x][theKey])){
+ value2 = lsParseNumber(theArray[x][theKey]);
+ }
+ else{
+ value2 = 9999;
+ }
}
else{
value1 = theArray[x + 1][theKey];

0 comments on commit 7e3ab2f

Please sign in to comment.