Skip to content

Commit

Permalink
Merge pull request #42 from aliaspooryorik/master
Browse files Browse the repository at this point in the history
Added new CF10 array & list functions
  • Loading branch information
aliaspooryorik committed Jun 23, 2012
2 parents 1b829c3 + daa1953 commit 7607b63
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Koans/AboutArrays.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,48 @@ component extends="Koans.BaseKoan"{
// hint: arraySwap switches element positions
assertEquals(__,myArray[1]);
}

/**
*@order 23
*/
public void function testArraySliceOffsetCF10(){
// new in CF10
// http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSf23b27ebc7b554b647112c9713585f0e10e-8000.html
if(application.version >= 10){
var myArray = ["Luke","Leia","Yoda","Chewbacca"];
var result = arraySlice(myArray, 3);
// what is the first element of the array?
assertEquals(__,result[1]);
}
}

/**
*@order 24
*/
public void function testArraySliceOffsetLengthCF10(){
// new in CF10
// http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSf23b27ebc7b554b647112c9713585f0e10e-8000.html
if(application.version >= 10){
var myArray = ["Luke","Leia","Yoda","Chewbacca","Han","Darth Vader"];
var result = arraySlice(myArray, 2, 3);
// how many elements are there in the array?
assertEquals(__,ArrayLen(result));
}
}

/**
*@order 24
*/
public void function testArraySliceNegativeCF10(){
// new in CF10
// http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSf23b27ebc7b554b647112c9713585f0e10e-8000.html
if(application.version >= 10){
var myArray = ["Luke","Leia","Yoda","Chewbacca","Han","Darth Vader"];
var result = arraySlice(myArray, -2, 1);
// what is the first element of the array?
// hint: a negative value means that CF counts from the end of the array
assertEquals(__,result[1]);
}
}

}
32 changes: 32 additions & 0 deletions Koans/AboutLists.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1043,5 +1043,37 @@ component extends="Koans.BaseKoan"{
// What gets returned?? That's tidier.
assertEquals(__,listToArrayResult);
}

/**
*@order 53
*/
function testCaseSensitiveListRemoveDuplicatesCF10(){
// listRemoveDuplicates is new in ColdFusion 10
// see: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSd8001ae4abdbd911-7fc6f4b01350d8e2282-8000.html
if(application.version >= 10){
var myList = "The cat in the hat sat on the mat";
// case insensitive remove duplicates
var result = ListRemoveDuplicates(myList, " ");

// What gets returned?
assertEquals(__,result);
}
}

/**
*@order 54
*/
function testCaseInSensitiveListRemoveDuplicatesCF10(){
// listRemoveDuplicates is new in ColdFusion 10
// see: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSd8001ae4abdbd911-7fc6f4b01350d8e2282-8000.html
if(application.version >= 10){
var myList = "The cat in the hat sat on the mat";
// case sensitive remove duplicates
var result = ListRemoveDuplicates(myList, " ", true);

// What gets returned??
assertEquals(__,result);
}
}

}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Niall O'Doherty [@nodoherty](http://twitter.com/#!/nodoherty) [http://www.niallo

Miles Rausch [@awayken](https://twitter.com/awayken) [http://milesrausch.com](http://milesrausch.com)

John Whish [@aliaspooryorik](https://twitter.com/aliaspooryorik) [http://www.aliaspooryorik.com/](http://www.aliaspooryorik.com)

##Thanks

Robert Glover [@snarfblat](http://twitter.com/#!/snarfblat) for helping me troubleshoot issues.

0 comments on commit 7607b63

Please sign in to comment.