js/src/jit-test/tests/basic/bug791465.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/basic/bug791465.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +load(libdir + "asserts.js");
     1.5 +
     1.6 +var valid_strict_funs = [
     1.7 +  // directive ends on next line
     1.8 +  function () {
     1.9 +    "use strict"
    1.10 +    ;
    1.11 +  },
    1.12 +  function () {
    1.13 +    "use strict"
    1.14 +  },
    1.15 +  // directive ends on same line
    1.16 +  function () { "use strict"; },
    1.17 +  function () { "use strict" },
    1.18 +];
    1.19 +
    1.20 +for (var f of valid_strict_funs) {
    1.21 +  assertThrowsInstanceOf(function() { f.caller }, TypeError);
    1.22 +}
    1.23 +
    1.24 +
    1.25 +var binary_ops = [
    1.26 +  "||", "&&",
    1.27 +  "|", "^", "&",
    1.28 +  "==", "!=", "===", "!==",
    1.29 +  "<", "<=", ">", ">=", "in", "instanceof",
    1.30 +  "<<", ">>", ">>>",
    1.31 +  "+", "-",
    1.32 +  "*", "/", "%",
    1.33 +];
    1.34 +
    1.35 +var invalid_strict_funs = [
    1.36 +  function () {
    1.37 +    "use strict"
    1.38 +    , "not";
    1.39 +  },
    1.40 +  function () {
    1.41 +    "use strict"
    1.42 +    ? 1 : 0;
    1.43 +  },
    1.44 +  function () {
    1.45 +    "use strict"
    1.46 +    .length;
    1.47 +  },
    1.48 +  function () {
    1.49 +    "use strict"
    1.50 +    [0];
    1.51 +  },
    1.52 +  function () {
    1.53 +    "use strict"
    1.54 +    ();
    1.55 +  },
    1.56 +  ...([]),
    1.57 +  ...[Function("'use strict'\n " + op + " 'not'") for (op of binary_ops)],
    1.58 +];
    1.59 +
    1.60 +for (var f of invalid_strict_funs) {
    1.61 +  f.caller;
    1.62 +}
    1.63 +
    1.64 +
    1.65 +var assignment_ops = [
    1.66 +   "=", "+=", "-=",
    1.67 +  "|=", "^=", "&=",
    1.68 +  "<<=", ">>=", ">>>=",
    1.69 +  "*=", "/=", "%=",
    1.70 +];
    1.71 +
    1.72 +var invalid_strict_funs_referror = [
    1.73 +  ...[("'use strict'\n " + op + " 'not'") for (op of assignment_ops)],
    1.74 +];
    1.75 +
    1.76 +// assignment with string literal as LHS is an early error, therefore we
    1.77 +// can only test for ReferenceError
    1.78 +for (var f of invalid_strict_funs_referror) {
    1.79 +  assertThrowsInstanceOf(function() { Function(f) }, ReferenceError);
    1.80 +}

mercurial