ggaren@apple.com | fb7031a | 2011-05-04 18:56:30 +0000 | [diff] [blame] | 1 | <p>Tests for compilation errors in trivial functions.</p> |
| 2 | <pre id="console"></pre> |
| 3 | |
| 4 | <p id="p"></p> |
| 5 | |
| 6 | <script> |
| 7 | function $(id) |
| 8 | { |
| 9 | return document.getElementById(id); |
| 10 | } |
| 11 | |
| 12 | function log(s) |
| 13 | { |
| 14 | $("console").appendChild(document.createTextNode(s + "\n")); |
| 15 | } |
| 16 | |
| 17 | function shouldBe(aDescription, a, b) |
| 18 | { |
| 19 | if (a == b) { |
| 20 | log("PASS: " + aDescription + " should be " + b + " and is."); |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + "."); |
| 25 | } |
| 26 | |
| 27 | function f1(a, b) { return a[b]; } |
| 28 | function f2(a, b, c) { return a[b] = c; } |
| 29 | |
rniwa@webkit.org | 03b9c6d | 2012-07-16 01:41:53 +0000 | [diff] [blame] | 30 | if (window.testRunner) |
| 31 | testRunner.dumpAsText(); |
ggaren@apple.com | fb7031a | 2011-05-04 18:56:30 +0000 | [diff] [blame] | 32 | |
| 33 | shouldBe("f1(0, 0)", f1(0, 0), undefined); |
| 34 | shouldBe("f2(0, 0, 0)", f2(0, 0, 0), 0); |
| 35 | </script> |