Skip to content

Commit

Permalink
FLUID-6091: Compact syntax with empty argument list should supply no …
Browse files Browse the repository at this point in the history
…arguments
  • Loading branch information
amb26 committed Dec 5, 2016
1 parent 73f7f90 commit cd2511f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/framework/core/js/FluidIoC.js
Expand Up @@ -1996,8 +1996,8 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
fluid.fail("Badly-formed compact " + type + " record " + string + " - unexpected material following close parenthesis: " + trail);
}
var prefix = string.substring(0, openPos);
var body = string.substring(openPos + 1, closePos);
var args = fluid.transform(body.split(","), $.trim, fluid.coerceToPrimitive);
var body = $.trim(string.substring(openPos + 1, closePos));
var args = body === "" ? [] : fluid.transform(body.split(","), $.trim, fluid.coerceToPrimitive);
var togo = fluid.upgradePrimitiveFunc(prefix, null);
togo.args = args;
return togo;
Expand Down
10 changes: 10 additions & 0 deletions tests/framework-tests/core/js/FluidIoCTests.js
Expand Up @@ -3534,6 +3534,11 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
that.one = value1;
};

fluid.tests.fluid6091check = function () {
jqUnit.assertDeepEq("FLUID-6091: Should have been supplied empty argument list", [], fluid.makeArray(arguments));
return arguments[0];
};

fluid.defaults("fluid.tests.fluid5127root", {
gradeNames: ["fluid.component"],
members: {
Expand All @@ -3550,6 +3555,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
},
invokers: {
addOne: "fluid.tests.add({that}.one, {arguments}.0)",
noArgs: "fluid.tests.fluid6091check()",
bindRecord: "fluid.tests.fluid5127listener({arguments}.0, {arguments}.1, {that})"
},
events: {
Expand All @@ -3576,11 +3582,15 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertEquals("Number", 3.5, that.number);
jqUnit.assertEquals("true", true, that["true"]);
jqUnit.assertEquals("false", false, that["false"]);
jqUnit.assertEquals("false", false, that["false"]);

var added = that.addOne(2);
jqUnit.assertEquals("Compact invoker", 3, added);
jqUnit.assertEquals("Expander to invoker", 3, that.addedInvoke);

var noArgs = that.noArgs();
jqUnit.assertEquals("No args supply no arguments", undefined, noArgs);

that.events.addEvent.fire(1);
jqUnit.assertEquals("Compact direct listener", 2, that.fireValue);

Expand Down

0 comments on commit cd2511f

Please sign in to comment.