From 13202e726e9479b951ad1bdf0a129a048e48bb76 Mon Sep 17 00:00:00 2001 From: msridhar1 Date: Fri, 6 Jan 2012 21:43:37 +0000 Subject: [PATCH] Added test case for handling of arguments array. git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4388 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../examples-src/tests/arguments.js | 15 +++++++++++++++ .../cast/js/test/TestSimpleCallGraphShape.java | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 com.ibm.wala.cast.js.test/examples-src/tests/arguments.js diff --git a/com.ibm.wala.cast.js.test/examples-src/tests/arguments.js b/com.ibm.wala.cast.js.test/examples-src/tests/arguments.js new file mode 100644 index 000000000..4b413e373 --- /dev/null +++ b/com.ibm.wala.cast.js.test/examples-src/tests/arguments.js @@ -0,0 +1,15 @@ +function f() { + arguments[0].g(); +} +f.g = function g1() {}; + +var o = { + f: f, + g: function g2() { } +} + +var oo = { + g: function g3() { } +} + +o.f(oo); \ 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 4c6b4e6bd..fd62f88dc 100755 --- 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 @@ -436,6 +436,18 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape { verifyGraphAssertions(CG, assertionsForReturnThis2); } + private static final Object[][] assertionsForArguments = new Object[][] { + new Object[] { ROOT, new String[] { "tests/arguments.js" } }, + new Object[] { "suffix:arguments.js", new String[] { "suffix:f" } }, + new Object[] { "suffix:f", new String[] { "suffix:g3" } } // but neither "suffix:g1" nor "suffix:g2" + }; + + @Test + public void testArguments() throws IOException, IllegalArgumentException, CancelException { + CallGraph CG = Util.makeScriptCG("tests", "arguments.js"); + verifyGraphAssertions(CG, assertionsForArguments); + } + private static final Object[][] assertionsForFunctionIsAFunction = new Object[][] { new Object[] { ROOT, new String[] { "tests/Function_is_a_function.js" } }, new Object[] { "suffix:Function_is_a_function.js", new String[] { "suffix:functionCall" } } };