Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Struct call(PageContext pc, Struct base) throws PageException {
}

public static Struct call(PageContext pc, Struct base, Object sortTypeOrSortFunc) throws PageException {
if(Decision.isSimpleValue(sortTypeOrSortFunc)) call(pc, base, Caster.toString(sortTypeOrSortFunc), "asc", false);
if(Decision.isSimpleValue(sortTypeOrSortFunc)) return call(pc, base, Caster.toString(sortTypeOrSortFunc), "asc", false);
return _call(pc, base, Caster.toFunction(sortTypeOrSortFunc));
}

Expand Down
49 changes: 49 additions & 0 deletions test/tickets/LDEV6302.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
component extends="org.lucee.cfml.test.LuceeTestCase" label="LDEV-6302"{

function beforeAll() {

// Struct with mixed-case keys for text and textNoCase tests
variables.textStruct = {
Zulu: { label: "Zulu" },
alpha: { label: "Alpha" },
MIKE: { label: "Mike" }
};

// Struct for numeric test
variables.numericStruct = {
"10": "ten",
"2": "two",
"1": "one"
};

}

function run( testResults, testBox ) {
describe( title="LDEV-6302: struct.toSorted/StructToSorted single-argument string defaults sortOrder to asc", body=function() {
it( title="member toSorted('text') with one argument defaults to ascending order", body=function( currentSpec ) {
expect(
structKeyList(duplicate(variables.textStruct).toSorted("text"), ",")
).toBe("alpha,MIKE,Zulu");
} );

it( title="member toSorted('textNoCase') with one argument defaults to ascending order", body=function( currentSpec ) {
expect(
structKeyList(duplicate(variables.textStruct).toSorted("textNoCase"), ",")
).toBe("alpha,MIKE,Zulu");
} );

it( title="member toSorted('numeric') with one argument defaults to ascending order", body=function( currentSpec ) {
expect(
structKeyList(duplicate(variables.numericStruct).toSorted("numeric"), ",")
).toBe("1,2,10");
} );

it( title="StructToSorted(base,'text') with one argument defaults to ascending order", body=function( currentSpec ) {
expect(
structKeyList(StructToSorted(duplicate(variables.textStruct), "text"), ",")
).toBe("alpha,MIKE,Zulu");
} );
} );
}

}
Loading