X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/tests/controlFlowProfiler/switch-statements.js?ds=sidebyside diff --git a/tests/controlFlowProfiler/switch-statements.js b/tests/controlFlowProfiler/switch-statements.js new file mode 100644 index 0000000..edcfbbf --- /dev/null +++ b/tests/controlFlowProfiler/switch-statements.js @@ -0,0 +1,28 @@ +load("./driver/driver.js"); + +var a, b, c; +function testSwitch(s) { + switch (s) { + case "foo": + return a; + case "bar": + return b; + default: + return c; + } +} + +assert(!hasBasicBlockExecuted(testSwitch, "switch"), "should not have executed yet."); + +testSwitch("foo"); +assert(hasBasicBlockExecuted(testSwitch, "switch"), "should have executed."); +assert(hasBasicBlockExecuted(testSwitch, "return a"), "should have executed."); +assert(!hasBasicBlockExecuted(testSwitch, "return b"), "should not have executed yet."); +assert(!hasBasicBlockExecuted(testSwitch, "return c"), "should not have executed yet."); + +testSwitch("bar"); +assert(hasBasicBlockExecuted(testSwitch, "return b"), "should have executed."); +assert(!hasBasicBlockExecuted(testSwitch, "return c"), "should not have executed yet."); + +testSwitch(""); +assert(hasBasicBlockExecuted(testSwitch, "return c"), "should have executed.");