this
null
42
(1 + 2 ) * 3
(1) + (2 ) + 3
4 + 5 << (6)
x = []
x = [ ]
x = [ 42 ]
x = [ 42, ]
x = [ ,, 42 ]
x = [ 1, 2, 3, ]
x = [ 1, 2,, 3, ]
x = [ "finally", "for" ]
日本語 = []
T‿ = []
T = []
T = []
ⅣⅡ = []
ⅣⅡ = []
[",", "second"]
["notAToken", "if"]
x = {}
x = { }
x = { answer: 42 }
x = { if: 42 }
x = { true: 42 }
x = { false: 42 }
x = { null: 42 }
x = { "answer": 42 }
x = { x: 1, x: 2 }
x = { get width() { return m_width } }
x = { get undef() {} }
x = { get if() {} }
x = { get true() {} }
x = { get false() {} }
x = { get null() {} }
x = { get "undef"() {} }
x = { get 10() {} }
x = { set width(w) { m_width = w } }
x = { set if(w) { m_if = w } }
x = { set true(w) { m_true = w } }
x = { set false(w) { m_false = w } }
x = { set null(w) { m_null = w } }
x = { set "null"(w) { m_null = w } }
x = { set 10(w) { m_null = w } }
x = { get: 42 }
x = { set: 43 }
x = { __proto__: 2 }
x = {"__proto__": 2 }
x = { get width() { return m_width }, set width(width) { m_width = width; } }
/* block comment */ 42
42 /*The*/ /*Answer*/
42 /*the*/ /*answer*/
42 /* the * answer */
42 /* The * answer */
/* multiline
comment
should
be
ignored */ 42
/*a
b*/ 42
/*a
b*/ 42
/*a
b*/ 42
/*a
c*/ 42
// line comment
42
42 // line comment
// Hello, world!
42
// Hello, world!
// Hallo, world!
//
42
//
//
/**/42
// Hello, world!
// Another hello
42
if (x) { // Some comment
doThat(); }
switch (answer) { case 42: /* perfect */ bingo() }
0
3
5
42
.14
3.14159
6.02214179e+23
1.492417830e-10
0x0
0x0;
0e+100
0e+100
0xabc
0xdef
0X1A
0x10
0x100
0X04
02
012
0012
"Hello"
"\n\r\t\v\b\f\\\'\"\0"
"\u0061"
"\x61"
"\u00"
"\xt"
"Hello\nworld"
"Hello\
world"
"Hello\02World"
"Hello\012World"
"Hello\122World"
"Hello\0122World"
"Hello\312World"
"Hello\412World"
"Hello\812World"
"Hello\712World"
"Hello\0World"
"Hello\
world"
"Hello\1World"
var x = /[a-z]/i
var x = /[x-z]/i
var x = /[a-c]/i
var x = /[P QR]/i
var x = /foo\/bar/
var x = /=([^=\s])+/g
var x = /[P QR]/\u0067
var x = /[P QR]/\g
var x = /42/g.test
new Button
new Button()
new new foo
new new foo()
new foo().bar()
new foo[bar]
new foo.bar()
( new foo).bar()
foo(bar, baz)
( foo )()
universe.milkyway
universe.milkyway.solarsystem
universe.milkyway.solarsystem.Earth
universe[galaxyName, otherUselessName]
universe[galaxyName]
universe[42].galaxies
universe(42).galaxies
universe(42).galaxies(14, 3, 77).milkyway
earth.asia.Indonesia.prepareForElection(2014)
universe.if
universe.true
universe.false
universe.null
x++
x--
eval++
eval--
arguments++
arguments--
++x
--x
++eval
--eval
++arguments
--arguments
+x
-x
~x
!x
void x
delete x
typeof x
x * y
x / y
x % y
x + y
x - y
"use strict" + 42
x << y
x >> y
x >>> y
x < y
x > y
x <= y
x >= y
x in y
x instanceof y
x < y < z
x == y
x != y
x === y
x !== y
x & y
x ^ y
x | y
x + y + z
x - y + z
x + y - z
x - y - z
x + y * z
x + y / z
x - y % z
x * y * z
x * y / z
x * y % z
x % y * z
x << y << z
x | y | z
x & y & z
x ^ y ^ z
x & y | z
x | y ^ z
x | y & z
x || y
x && y
x || y || z
x && y && z
x || y && z
x || y ^ z
y ? 1 : 2
x && y ? 1 : 2
x = 42
eval = 42
arguments = 42
x *= 42
x /= 42
x %= 42
x += 42
x -= 42
x <<= 42
x >>= 42
x >>>= 42
x &= 42
x ^= 42
x |= 42
a || b && c | d ^ e & f == g < h >>> i + j * k
{ foo }
{ doThis(); doThat(); }
{}
var x
var x, y;
var x = 42
var eval = 42, arguments = 42
var x = 14, y = 3, z = 1977
var implements, interface, package
var private, protected, public, static
let x
{ let x }
{ let x = 42 }
{ let x = 14, y = 3, z = 1977 }
const x = 42
{ const x = 42 }
{ const x = 14, y = 3, z = 1977 }
;
x
x, y
\u0061
a\u0061
\u0061a
\u0061a
if (morning) goodMorning()
if (morning) (function(){})
if (morning) var x = 0;
if (morning) function a(){}
if (morning) goodMorning(); else goodDay()
do keep(); while (true)
do keep(); while (true);
do { x++; y--; } while (x < 10)
{ do { } while (false) false }
while (true) doSomething()
while (x < 10) { x++; y--; }
for(;;);
for(;;){}
for(x = 0;;);
for(var x = 0;;);
for(let x = 0;;);
for(var x = 0, y = 1;;);
for(x = 0; x < 42;);
for(x = 0; x < 42; x++);
for(x = 0; x < 42; x++) process(x);
for(x in list) process(x);
for (var x in list) process(x);
for (let x in list) process(x);
for (var i = function() { return 10 in [] } of list) process(x);
while (true) { continue; }
while (true) { continue }
done: while (true) { continue done }
done: while (true) { continue done; }
__proto__: while (true) { continue __proto__; }
while (true) { break }
done: while (true) { break done }
done: while (true) { break done; }
__proto__: while (true) { break __proto__; }
(function(){ return })
(function(){ return; })
(function(){ return x; })
(function(){ return x * y })
with (x) foo = bar
with (x) foo = bar;
with (x) { foo = bar }
switch (x) {}
switch (answer) { case 42: hi(); break; }
switch (answer) { case 42: hi(); break; default: break }
start: for (;;) break start
start: while (true) break start
__proto__: test
throw x;
throw x * y
throw { message: "Error" }
try { } catch (e) { }
try { } catch (eval) { }
try { } catch (arguments) { }
try { } catch (e) { say(e) }
try { } finally { cleanup(stuff) }
try { doThat(); } catch (e) { say(e) }
try { doThat(); } catch (e) { say(e) } finally { cleanup(stuff) }
debugger;
function hello() { sayHi(); }
function eval() { }
function arguments() { }
function test(t, t) { }
(function test(t, t) { })
function eval() { function inner() { "use strict" } }
function hello(a) { sayHi(); }
function hello(a, b) { sayHi(); }
var hi = function() { sayHi() };
var hi = function eval() { };
var hi = function arguments() { };
var hello = function hi() { sayHi() };
(function(){})
function universe(__proto__) { }
function test() { "use strict" + 42; }
{ x
++y }
{ x
--y }
var x /* comment */;
{ var x = 14, y = 3
z; }
while (true) { continue
there; }
while (true) { continue // Comment
there; }
while (true) { continue /* Multiline
Comment */there; }
while (true) { break
there; }
while (true) { break // Comment
there; }
while (true) { break /* Multiline
Comment */there; }
(function(){ return
x; })
(function(){ return // Comment
x; })
(function(){ return/* Multiline
Comment */x; })
{ throw error
error; }
{ throw error// Comment
error; }
{ throw error/* Multiline
Comment */error; }
x + y - z
a + (b < (c * d)) + e
{
}
3ea
3in []
3e
3e+
3e-
3x
3x0
0x
09
018
01a
3in[]
0x3in[]
"Hello
World"
x\
x\u005c
x\u002a
var x = /(s/g
a\u
\ua
/
/test
var x = /[a-z]/\ux
3 = 4
func() = 4
(1 + 1) = 10
1++
1--
++1
--1
for((1 + 1) in list) process(x);
[
[,
1 + {
1 + { t:t
1 + { t:t,
var x = /
/
var x = "
var if = 42
i #= 42
i + 2 = 42
+i = 42
1 + (
{
/* Some multiline
comment */
)
{ set 1 }
{ get 2 }
({ set: s(if) { } })
({ set s(.) { } })
({ set: s() { } })
({ set: s(a, b) { } })
({ get: g(d) { } })
({ get i() { }, i: 42 })
({ i: 42, get i() { } })
({ set i(x) { }, i: 42 })
({ i: 42, set i(x) { } })
({ get i() { }, get i() { } })
({ set i(x) { }, set i(x) { } })
function t(if) { }
function t(true) { }
function t(false) { }
function t(null) { }
function null() { }
function true() { }
function false() { }
function if() { }
a b;
if.a;
a if;
a class;
break
break 1;
continue
continue 2;
throw
throw;
throw
for (var i, i2 in {});
for ((i in {}));
for (i + 1 in {});
for (+i in {});
if(false)
if(false) doThis(); else
do
while(false)
for(;;)
with(x)
try { }
‿ = 10
const x = 12, y;
const x, y = 12;
const x;
if(true) let a = 1;
if(true) const a = 1;
switch (c) { default: default: }
new X()."s"
/*
/*
/**
/*
*
/*hello
/*hello *
]
]
]
]
//
]
//
]
/a\
/
//
]
/*
*/]
/*
*/]
/*
*/]
\\
\u005c
\x
\u0000
= []
= []
"\
"\u
try { } catch() {}
return
break
continue
switch (x) { default: continue; }
do { x } *
while (true) { break x; }
while (true) { continue x; }
x: while (true) { (function () { break x; }); }
x: while (true) { (function () { continue x; }); }
x: while (true) { (function () { break; }); }
x: while (true) { (function () { continue; }); }
x: while (true) { x: while (true) { } }
(function () { 'use strict'; delete i; }())
(function () { 'use strict'; with (i); }())
function hello() {'use strict'; ({ i: 42, i: 42 }) }
function hello() {'use strict'; ({ hasOwnProperty: 42, hasOwnProperty: 42 }) }
function hello() {'use strict'; var eval = 10; }
function hello() {'use strict'; var arguments = 10; }
function hello() {'use strict'; try { } catch (eval) { } }
function hello() {'use strict'; try { } catch (arguments) { } }
function hello() {'use strict'; eval = 10; }
function hello() {'use strict'; arguments = 10; }
function hello() {'use strict'; ++eval; }
function hello() {'use strict'; --eval; }
function hello() {'use strict'; ++arguments; }
function hello() {'use strict'; --arguments; }
function hello() {'use strict'; eval++; }
function hello() {'use strict'; eval--; }
function hello() {'use strict'; arguments++; }
function hello() {'use strict'; arguments--; }
function hello() {'use strict'; function eval() { } }
function hello() {'use strict'; function arguments() { } }
function eval() {'use strict'; }
function arguments() {'use strict'; }
function hello() {'use strict'; (function eval() { }()) }
function hello() {'use strict'; (function arguments() { }()) }
(function eval() {'use strict'; })()
(function arguments() {'use strict'; })()
function hello() {'use strict'; ({ s: function eval() { } }); }
(function package() {'use strict'; })()
function hello() {'use strict'; ({ i: 10, set s(eval) { } }); }
function hello() {'use strict'; ({ set s(eval) { } }); }
function hello() {'use strict'; ({ s: function s(eval) { } }); }
function hello(eval) {'use strict';}
function hello(arguments) {'use strict';}
function hello() { 'use strict'; function inner(eval) {} }
function hello() { 'use strict'; function inner(arguments) {} }
"\1"; 'use strict';
function hello() { 'use strict'; "\1"; }
function hello() { 'use strict'; 021; }
function hello() { 'use strict'; ({ "\1": 42 }); }
function hello() { 'use strict'; ({ 021: 42 }); }
function hello() { "octal directive\1"; "use strict"; }
function hello() { "octal directive\1"; "octal directive\2"; "use strict"; }
function hello() { "use strict"; function inner() { "octal directive\1"; } }
function hello() { "use strict"; var implements; }
function hello() { "use strict"; var interface; }
function hello() { "use strict"; var package; }
function hello() { "use strict"; var private; }
function hello() { "use strict"; var protected; }
function hello() { "use strict"; var public; }
function hello() { "use strict"; var static; }
function hello() { "use strict"; var yield; }
function hello() { "use strict"; var let; }
function hello(static) { "use strict"; }
function static() { "use strict"; }
function eval(a) { "use strict"; }
function arguments(a) { "use strict"; }
var yield
var let
"use strict"; function static() { }
function a(t, t) { "use strict"; }
function a(eval) { "use strict"; }
function a(package) { "use strict"; }
function a() { "use strict"; function b(t, t) { }; }
(function a(t, t) { "use strict"; })
function a() { "use strict"; (function b(t, t) { }); }
(function a(eval) { "use strict"; })
(function a(package) { "use strict"; })
__proto__: __proto__: 42;
"use strict"; function t(__proto__, __proto__) { }
"use strict"; x = { __proto__: 42, __proto__: 43 }
"use strict"; x = { get __proto__() { }, __proto__: 43 }
var
let
const
{ ; ;
function t() { ; ;
tokenize(/42/)
if (false) { /42/ }
with (false) /42/
(false) /42/
function f(){} /42/
function(){} /42
{} /42
[function(){} /42]
;function f(){} /42/
void /42/
/42/
foo[/42]
/42
foo[/42
parse()
parse(null)
parse(42)
parse(true)
parse(undefined)
parse(new String("test"))
parse(new Number(42))
parse(new Boolean(true))
Syntax
tokenize()
tokenize(null)
tokenize(42)
tokenize(true)
tokenize(undefined)
tokenize(new String("test"))
tokenize(new Number(42))
tokenize(new Boolean(true))
return
(function () { 'use strict'; with (i); }())
(function () { 'use strict'; 021 }())
"use strict"; delete x
"use strict"; try {} catch (eval) {}
"use strict"; try {} catch (arguments) {}
"use strict"; var eval;
"use strict"; var arguments;
"use strict"; eval = 0;
"use strict"; eval++;
"use strict"; --eval;
"use strict"; arguments = 0;
"use strict"; arguments--;
"use strict"; ++arguments;
"use strict";x={y:1,y:1}
"use strict"; function eval() {};
"use strict"; function arguments() {};
"use strict"; function interface() {};
"use strict"; (function eval() {});
"use strict"; (function arguments() {});
"use strict"; (function interface() {});
"use strict"; function f(eval) {};
"use strict"; function f(arguments) {};
"use strict"; function f(foo, foo) {};
"use strict"; (function f(eval) {});
"use strict"; (function f(arguments) {});
"use strict"; (function f(foo, foo) {});
"use strict"; x = { set f(eval) {} }
function hello() { "octal directive\1"; "use strict"; }
"\1"; 'use strict';
"use strict"; var x = { 014: 3}
"use strict"; var x = { get i() {}, get i() {} }
"use strict"; var x = { i: 42, get i() {} }
"use strict"; var x = { set i(x) {}, i: 42 }
"\u{714E}\u{8336}"
"\u{20BB7}\u{91CE}\u{5BB6}"
00
0o0
function test() {'use strict'; 0o0; }
0o2
0o12
0O0
function test() {'use strict'; 0O0; }
0O2
0O12
0b0
0b1
0b10
0B0
0B1
0B10
`42`
raw`42`
raw`hello ${name}`
`$`
`\n\r\b\v\t\f\
\
`
`
`
`\u{000042}\u0042\x42\u0\102\A`
new raw`42`
switch (answer) { case 42: let t = 42; break; }
() => "test"
e => "test"
(e) => "test"
(a, b) => "test"
e => { 42; }
e => ({ property: 42 })
e => { label: 42 }
(a, b) => { 42; }
([a, , b]) => 42
([a.a]) => 42
(x=1) => x * x
eval => 42
arguments => 42
(a) => 00
(eval, a) => 42
(eval = 10) => 42
(eval, a = 10) => 42
(x => x)
x => y => 42
(x) => ((y, z) => (x, y, z))
foo(() => {})
foo((x, y) => {})
x = { method() { } }
x = { method(test) { } }
x = { 'method'() { } }
x = { get() { } }
x = { set() { } }
x = { method() 42 }
x = { get method() 42 }
x = { set method(val) v = val }
[[x,b,c] for (x in []) for (b in []) if (b && c)]
[x for (a in [])]
[1 for (x in [])]
[(x,1) for (x in [])]
[x for (x of array)]
[x for (x of array) for (y of array2) if (x === test)]
x = { y, z }
[a, b] = [b, a]
({ responseText: text }) = res
const {a} = {}
const [a] = []
let {a} = {}
let [a] = []
var {a} = {}
var [a] = []
const {a:b} = {}
let {a:b} = {}
var {a:b} = {}
module "crypto" {}
module crypto from "crypto";
module "crypto/e" {}
export var document
export var document = { }
export let document
export let document = { }
export const document = { }
export function parse() { }
export class Class {}
export default = 42
export *
export * from "crypto"
export { encrypt }
export { encrypt, decrypt }
export { encrypt as default }
export { encrypt, decrypt as dec }
module "lib" { export var document }
module "lib" { export var document = { } }
module "lib" { export let document }
module "lib" { export let document = { } }
module "lib" { export const document = { } }
module "lib" { export function parse() { } }
module "lib" { export class Class {} }
module "lib" { export * }
module "security" { export * from "crypto" }
module "crypto" { export { encrypt } }
module "crypto" { export { encrypt, decrypt } }
module "crypto" { export { encrypt, decrypt as dec } }
import "jquery"
import $ from "jquery"
import { encrypt, decrypt } from "crypto"
import { encrypt as enc } from "crypto"
import { decrypt, encrypt as enc } from "crypto"
import default from "foo"
import { null as nil } from "bar"
module "security" { import "cryto" }
module()
module "foo" { module() }
(function* () { yield v })
(function* () { yield *v })
function* test () { yield *v }
var x = { *test () { yield *v } };
function* t() {}
(function* () { yield yield 10 })
for(x of list) process(x);
for (var x of list) process(x);
for (var x = 42 of list) process(x);
for (let x of list) process(x);
var A = class extends B {}
class A extends class B extends C {} {}
class A {get() {}}
class A { static get() {}}
class A extends B {get foo() {}}
class A extends B { static get foo() {}}
class A {set a(v) {}}
class A { static set a(v) {}}
class A {set(v) {};}
class A { static set(v) {};}
class A {*gen(v) { yield v; }}
class A { static *gen(v) { yield v; }}
"use strict"; (class A {constructor() { super() }})
class A {static foo() {}}
class A {foo() {} static bar() {}}
"use strict"; (class A { static constructor() { super() }})
class A { foo() {} bar() {}}
class A { get foo() {} set foo(v) {}}
class A { static get foo() {} get foo() {}}
class A { static get foo() {} static get bar() {} }
class A { static get foo() {} static set foo(v) {} get foo() {} set foo(v) {}}
class A { set foo(v) {} get foo() {} }
class A { get foo() {} get foo() {} }
class A { set foo(v) {} set foo(v) {} }
class A { get foo() {} foo() {} }
class A { foo() {} get foo() {} }
class A { set foo(v) {} foo() {} }
class A { foo() {} set foo(v) {} }
x = function(y = 1) {}
function f(a = 1) {}
x = { f: function(a=1) {} }
x = { f(a=1) {} }
function f(a, ...b) {}
function x([ a, b ]){}
function x({ a, b }){}
function x(a, { a }){}
function x(...[ a, b ]){}
function x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){}
(function x([ a, b ]){})
(function x({ a, b }){})
(function x(...[ a, b ]){})
(function x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){})
({ x([ a, b ]){} })
({ x(...[ a, b ]){} })
({ x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){} })
(...a) => {}
(a, ...b) => {}
({ a }) => {}
({ a }, ...b) => {}
(...[a, b]) => {}
(a, ...[b]) => {}
({ a: [a, b] }, ...c) => {}
({ a: b, c }, [d, e], ...f) => {}
[...a] = b
[a, ...b] = c
[{ a, b }, ...c] = d
[a, ...[b, c]] = d
var [...a] = b
var [a, ...b] = c
var [{ a, b }, ...c] = d
var [a, ...[b, c]] = d
func(...a)
func(a, ...b)
0o
0o1a
0o9
0o18
0O
0O1a
0O9
0O18
0b
0b1a
0b9
0b18
0b12
0B
0B1a
0B9
0B18
0B12
"\u{110000}"
"\u{}"
"\u{FFFF"
"\u{FFZ}"
[v] += ary
[2] = 42
({ obj:20 }) = 42
( { get x() {} } ) = 0
x
is y
x
isnt y
function default() {}
function hello() {'use strict'; ({ i: 10, s(eval) { } }); }
function a() { "use strict"; ({ b(t, t) { } }); }
var super
var default
let default
const default
({ v: eval }) = obj
({ v: arguments }) = obj
for (var i = function() { return 10 in [] } in list) process(x);
for (let x = 42 in list) process(x);
for (let x = 42 of list) process(x);
module
"crypto" {}
module foo from bar
module 42
module foo bar
module "crypto" { module "e" {} }
module "x" { export * from foo }
import foo
import { foo, bar }
import foo from bar
((a)) => 42
(a, (b)) => 42
"use strict"; (eval = 10) => 42
"use strict"; eval => 42
"use strict"; arguments => 42
"use strict"; (eval, a) => 42
"use strict"; (arguments, a) => 42
"use strict"; (eval, a = 10) => 42
(a, a) => 42
"use strict"; (a, a) => 42
"use strict"; (a) => 00
() <= 42
(10) => 00
(10, 20) => 00
yield v
yield 10
yield* 10
e => yield* 10
(function () { yield 10 })
(function () { yield* 10 })
(function* () { })
function* test () { }
var obj = { *test() { } }
var obj = { *test** }
class A extends yield B { }
class default
`test
switch `test`
`hello ${10 `test`
`hello ${10;test`
function a() 1 // expression closure is not supported
[a,b if (a)] // (a,b)
for each (let x in {}) {};
[x for (let x in [])]
[x for (const x in [])]
[x for (var x in [])]
[a,b for (a in [])] // (a,b)
[x if (x)] // block required
var a = [x if (x)]
[for (x in [])] // no espression
({ "chance" }) = obj
({ 42 }) = obj
function f(a, ...b, c)
function f(a, ...b = 0)
function x(...{ a }){}
"use strict"; function x(a, { a }){}
"use strict"; function x({ b: { a } }, [{ b: { a } }]){}
"use strict"; function x(a, ...[a]){}
(...a, b) => {}
([ 5 ]) => {}
({ 5 }) => {}
(...[ 5 ]) => {}
[...{ a }] = b
[...a, b] = c
func(...a, b)
({ t(eval) { "use strict"; } });
"use strict"; `${test}\02`;
[...a, ] = b
if (b,...a, );
(b, ...a)
module "Universe" { ; ;
switch (cond) { case 10: let a = 20;
"use strict"; (eval) => 42
(eval) => { "use strict"; 42 }
({ get test() { } }) => 42
A software project is only as good as its QA workflow. This set of unit tests makes sure that no regression is ever sneaked in.
Version being tested: 1.1.0-dev-harmony.
Esprima is created and mantained by Ariya Hidayat.