diff --git a/com.ibm.wala.cast.js.test/examples-src/tests/function_apply.js b/com.ibm.wala.cast.js.test/examples-src/tests/function_apply.js index 2c654bc7a..c72ab32e3 100644 --- a/com.ibm.wala.cast.js.test/examples-src/tests/function_apply.js +++ b/com.ibm.wala.cast.js.test/examples-src/tests/function_apply.js @@ -3,7 +3,7 @@ function biz() { return this; } var q = biz; var o = { m: function theOne() {} } var r = q.apply(o); -o.m() +r.m() function id(y) { return y; } @@ -14,3 +14,5 @@ s(); // test invoking with non-array argsList p.apply(null, o); + + diff --git a/com.ibm.wala.cast.js.test/examples-src/tests/function_apply2.js b/com.ibm.wala.cast.js.test/examples-src/tests/function_apply2.js new file mode 100644 index 000000000..3247ae443 --- /dev/null +++ b/com.ibm.wala.cast.js.test/examples-src/tests/function_apply2.js @@ -0,0 +1,9 @@ +// test use of arguments array +function useArgs() { + return arguments[2]; +} +var o = {} +function theThree() {} +var a = useArgs; +var b = a.apply(o, [o,o,theThree]); +b(); \ No newline at end of file diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShape.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShape.java index 54b881c19..b4c9c9174 100644 --- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShape.java +++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShape.java @@ -328,6 +328,16 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape { verifyGraphAssertions(CG, assertionsForFunctionApply); } + private static final Object[][] assertionsForFunctionApply2 = new Object[][] { + new Object[] { ROOT, new String[] { "tests/function_apply2.js" } }, + new Object[] { "suffix:function_apply2.js", new String[] { "suffix:theThree" } } }; + + @Test + public void testFunctionDotApply2() throws IOException, IllegalArgumentException, CancelException { + CallGraph CG = Util.makeScriptCG("tests", "function_apply2.js"); + verifyGraphAssertions(CG, assertionsForFunctionApply2); + } + private static final Object[][] assertionsForComplexCall = new Object[][] { new Object[] { ROOT, new String[] { "tests/complex_call.js" } }, new Object[] { "suffix:call.js", new String[] { "suffix:f3" } } };