From 5db60dcac9d346c9d4cef37292f2fdb66ac35f1e Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke parse function that takes a code string and
returns an abstract syntax tree as specified by Mozilla parser
API, with the caveat that the SpiderMonkey-specific syntax
-(let, yield, inline XML, etc) is not recognized, and that
-range information is attached directly to the AST nodes as
-start and end properties, rather than wrapped in an
-additional object under a loc property.
var options, input, inputLen;
+(let, yield, inline XML, etc) is not recognized. var options, input, inputLen;
exports.parse = function(inpt, opts) {
input = String(inpt); inputLen = input.length;
@@ -40,12 +37,12 @@ trailing commas in array and object literals. commentsBefore and commentsAfter array (of the nodes
after and before it), but never twice in the before (or after)
-array of different nodes. trackComments: false,By default, the start and end properties attached to nodes hold
-offsets into the file. When linePositions is on, they will hold
-{offset, line, column} (with line being 1-based and column
-0-based) instead.
linePositions: false
+array of different nodes. trackComments: false,When locations is on, loc properties holding objects with
+start and end properties in {line, column} form (with
+line being 1-based and column 0-based) will be attached to the
+nodes.
locations: false
};The getLineInfo function is mostly useful when the
-linePositions option is off (for performance reasons) and you
+locations option is off (for performance reasons) and you
want to find the line/column position for a given character
offset. input should be the code string that the offset refers
into.
var getLineInfo = exports.getLineInfo = function(input, offset) {
@@ -61,27 +58,26 @@ into. Acorn is organized as a tokenizer and a recursive-descent parser.
Both use (closure-)global variables to keep their state and
communicate. We already saw the options, input, and
-inputLen variables above (set in parse).
The current position of the tokenizer in the input.
var tokPos;The start and end positions of the current token. These hold
-integers when options.linePositions is false, and objects
-otherwise.
var tokStart, tokEnd;The type and value of the current token. Token types are objects,
+inputLen variables above (set in parse).
The current position of the tokenizer in the input.
var tokPos;The start and end offsets of the current token.
var tokStart, tokEnd;When options.locations is true, these hold objects
+containing the tokens start and end line/column pairs.
var tokStartLoc, tokEndLoc;The type and value of the current token. Token types are objects,
named by variables against which they can be compared, and
holding properties that describe them (indicating, for example,
the precedence of an infix operator, and the original name of a
keyword token). The kind of value that's held in tokVal depends
on the type of the token. For literals, it is the literal value,
-for operators, the operator name, and so on.
var tokType, tokVal;These are used to hold arrays of comments when
-options.trackComments is true.
var tokCommentsBefore, tokCommentsAfter;Interal state for the tokenizer. To distinguish between division +for operators, the operator name, and so on.
var tokType, tokVal;These are used to hold arrays of comments when
+options.trackComments is true.
var tokCommentsBefore, tokCommentsAfter;Interal state for the tokenizer. To distinguish between division
operators and regular expressions, it remembers whether the last
token was one that is allowed to be followed by an expression.
(If it is, a slash is probably a regexp, if it isn't it's a
division operator. See the parseStatement function for a
-caveat.)
var tokRegexpAllowed, tokComments;When options.linePositions is true, these are used to keep
+caveat.)
var tokRegexpAllowed, tokComments;When options.locations is true, these are used to keep
track of the current line, and know when a new line has been
-entered. See the curLinePos function.
var tokCurLine, tokLineStart, tokLineStartNext;These store the position of the previous token, which is useful
-when finishing a node and assigning its end position.
var lastStart, lastEnd;This is the parser's state. inFunction is used to reject
+entered. See the curLineLoc function.
var tokCurLine, tokLineStart, tokLineStartNext;These store the position of the previous token, which is useful
+when finishing a node and assigning its end position.
var lastStart, lastEnd, lastEndLoc;This is the parser's state. inFunction is used to reject
return statements outside of functions, labels to verify that
break and continue have somewhere to jump to, and strict
-indicates whether strict mode is on.
var inFunction, labels, strict;This function is used to raise exceptions on parse errors. It +indicates whether strict mode is on.
var inFunction, labels, strict;This function is used to raise exceptions on parse errors. It
takes either a {line, column} object or an offset integer (into
the current input) as pos argument. It attaches the position
to the end of the error message, and then raises a SyntaxError
@@ -89,12 +85,12 @@ with that message.
The assignment of fine-grained, information-carrying type objects + }
The assignment of fine-grained, information-carrying type objects allows the tokenizer to store the information it has about a -token in a way that is very cheap for the parser to look up.
All token type variables start with an underscore, to make them -easy to recognize.
These are the general types. The type property is only used to
+token in a way that is very cheap for the parser to look up.
All token type variables start with an underscore, to make them +easy to recognize.
These are the general types. The type property is only used to
make them recognizeable when debugging.
var _num = {type: "num"}, _regexp = {type: "regexp"}, _string = {type: "string"};
- var _name = {type: "name"}, _eof = {type: "eof"};Keyword tokens. The keyword property (also used in keyword-like
+ var _name = {type: "name"}, _eof = {type: "eof"};
Keyword tokens. The keyword property (also used in keyword-like
operators) indicates that the token originated from an
identifier-like word, which is used when parsing property names.
The keywords that denote values.
var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
- var _false = {keyword: "false", atomValue: false};Some keywords are treated as regular operators. in sometimes
+ var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
The keywords that denote values.
var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
+ var _false = {keyword: "false", atomValue: false};Some keywords are treated as regular operators. in sometimes
(when parsing for) needs to be tested against specifically, so
-we assign a variable name to it for quick comparing.
var _in = {keyword: "in", binop: 7, beforeExpr: true};Map keyword names to token types.
var keywordTypes = {"break": _break, "case": _case, "catch": _catch,
+we assign a variable name to it for quick comparing. var _in = {keyword: "in", binop: 7, beforeExpr: true};Map keyword names to token types.
var keywordTypes = {"break": _break, "case": _case, "catch": _catch,
"continue": _continue, "debugger": _debugger, "default": _default,
"do": _do, "else": _else, "finally": _finally, "for": _for,
"function": _function, "if": _if, "return": _return, "switch": _switch,
@@ -123,10 +119,10 @@ we assign a variable name to it for quick comparing. Punctuation token types. Again, the type property is purely for debugging.
var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
+ "delete": {keyword: "delete", prefix: true}};Punctuation token types. Again, the type property is purely for debugging.
var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
- var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};Operators. These carry several kinds of properties to help the + var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};
Operators. These carry several kinds of properties to help the parser use them properly (the presence of these properties is what categorizes them as operators).
@@ -147,7 +143,7 @@ in AssignmentExpression nodes.This is a trick taken from Esprima. It turns out that, on + var _bin10 = {binop: 10, beforeExpr: true};
This is a trick taken from Esprima. It turns out that, on
non-Chrome browsers, to check whether a string is in a set, a
predicate containing a big ugly switch statement is faster than
a regular expression, and on Chrome the two are about on par.
@@ -170,7 +166,7 @@ predicate from a space-separated string of words.
When there are more than three length categories, an outer + }
When there are more than three length categories, an outer switch first dispatches on the lengths, to save on comparisons.
if (cats.length > 3) {
cats.sort(function(a, b) {return b.length - a.length;});
f += "switch(str.length){";
@@ -179,54 +175,54 @@ switch first dispatches on the lengths, to save on comparisons.
f += "case " + cat[0].length + ":";
compareTo(cat);
}
- f += "}";Otherwise, simply generate a flat switch statement.
} else {
+ f += "}";Otherwise, simply generate a flat switch statement.
} else {
compareTo(words);
}
return (1, eval)(f + "})");
- }The ECMAScript 3 reserved word list.
var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");ECMAScript 5 reserved words.
var isReservedWord5 = makePredicate("class enum extends super const export import");The additional reserved words in strict mode.
var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");The forbidden variable names in strict mode.
var isStrictBadIdWord = makePredicate("eval arguments");And the keywords.
var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in");Big ugly regular expressions that match characters in the + }
The ECMAScript 3 reserved word list.
var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");ECMAScript 5 reserved words.
var isReservedWord5 = makePredicate("class enum extends super const export import");The additional reserved words in strict mode.
var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");The forbidden variable names in strict mode.
var isStrictBadIdWord = makePredicate("eval arguments");And the keywords.
var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in");Big ugly regular expressions that match characters in the whitespace, identifier, and identifier-start categories. These are only applied when a character is found to actually have a code point above 128.
var nonASCIIwhitespace = /[\u1680\u180E\u2000-\u200A\u202F\u205F\u3000\uFEFF]/;
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
var nonASCIIidentifierChars = "\u0371-\u0374\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
- var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");Whether a single character denotes a newline.
var newline = /[\n\r\u2028\u2029]/;Matches a whole line break (where CRLF is considered a single -line break). Used to count lines.
var lineBreak = /\r\n?|[\n\r\u2028\u2029]/g;Test whether a given character code starts an identifier.
function isIdentifierStart(code) {
+ var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");Whether a single character denotes a newline.
var newline = /[\n\r\u2028\u2029]/;Matches a whole line break (where CRLF is considered a single +line break). Used to count lines.
var lineBreak = /\r\n?|[\n\r\u2028\u2029]/g;Test whether a given character code starts an identifier.
function isIdentifierStart(code) {
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122) ||
code === 36 || code === 95 ||
(code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)));
- }Test whether a given character is part of an identifier.
function isIdentifierChar(ch) {
+ }Test whether a given character is part of an identifier.
function isIdentifierChar(ch) {
return ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") ||
(ch >= "0" && ch <= "9") || ch === "$" || ch === "_" ||
(ch >= "\xaa" && nonASCIIidentifier.test(ch)));
- }These are used when options.linePositions is on, in order to
-track the current line number and start of line offset, so that
-tokStart and tokEnd refer to position objects indead of
-integer offsets.
function nextLineStart() {
+ }These are used when options.locations is on, in order to track
+the current line number and start of line offset, in order to set
+tokStartLoc and tokEndLoc.
function nextLineStart() {
lineBreak.lastIndex = tokLineStart;
var match = lineBreak.exec(input);
return match ? match.index + match[0].length : input.length + 1;
}
- function curLinePos() {
+ function curLineLoc() {
while (tokLineStartNext <= tokPos) {
++tokCurLine;
tokLineStart = tokLineStartNext;
tokLineStartNext = nextLineStart();
}
- return {offset: tokPos, line: tokCurLine, column: tokPos - tokLineStart};
- }Reset the token state. Used at the start of a parse.
function initTokenState() {
+ return {line: tokCurLine, column: tokPos - tokLineStart};
+ }Reset the token state. Used at the start of a parse.
function initTokenState() {
tokCurLine = 1;
tokPos = tokLineStart = 0;
tokLineStartNext = nextLineStart();
tokRegexpAllowed = true;
tokComments = null;
skipSpace();
- }Called at the end of every token. Sets tokEnd, tokVal,
+ }
Called at the end of every token. Sets tokEnd, tokVal,
tokCommentsAfter, and tokRegexpAllowed, and skips the space
after the token, so that the next one's tokStart will point at
the right position.
function finishToken(type, val) {
- tokEnd = options.linePositions ? curLinePos() : tokPos;
+ tokEnd = tokPos;
+ if (options.locations) tokEndLoc = curLineLoc();
tokType = type;
skipSpace();
tokVal = val;
@@ -248,7 +244,7 @@ the right position. Called at the start of the parse and after every token. Skips + }
Called at the start of the parse and after every token. Skips
whitespace and comments, and, if options.trackComments is on,
will store all skipped comments in tokComments.
function skipSpace() {
tokComments = null;
@@ -268,7 +264,7 @@ will store all skipped comments in tokComments. break;
}
}
- }This is the function that is called to fetch the next token. It + }
This is the function that is called to fetch the next token. It is somewhat obscure, because it works in character codes rather than characters, and because operator parsing has been inlined into it.
@@ -277,20 +273,21 @@ into it.The forceRegexp parameter is used in the one case where the
tokRegexpAllowed trick does not work. See parseStatement.
function readToken(forceRegexp) {
- tokStart = options.linePositions ? curLinePos() : tokPos;
+ tokStart = tokPos;
+ if (options.locations) tokStartLoc = curLineLoc();
tokCommentsBefore = tokComments;
if (forceRegexp) return readRegexp();
if (tokPos >= inputLen) return finishToken(_eof);
- var code = input.charCodeAt(tokPos);Identifier or keyword. '\uXXXX' sequences are allowed in + var code = input.charCodeAt(tokPos);
Identifier or keyword. '\uXXXX' sequences are allowed in identifiers, so '\' also dispatches to that.
if (isIdentifierStart(code) || code === 92 /* '\' */) return readWord();
var next = input.charCodeAt(tokPos+1);
- switch(code) {The interpretation of a dot depends on whether it is followed + switch(code) {
The interpretation of a dot depends on whether it is followed by a digit.
case 46: // '.'
if (next >= 48 && next <= 57) return readNumber(String.fromCharCode(code));
++tokPos;
- return finishToken(_dot);Punctuation tokens.
case 40: ++tokPos; return finishToken(_parenL);
+ return finishToken(_dot);Punctuation tokens.
case 40: ++tokPos; return finishToken(_parenL);
case 41: ++tokPos; return finishToken(_parenR);
case 59: ++tokPos; return finishToken(_semi);
case 44: ++tokPos; return finishToken(_comma);
@@ -299,11 +296,11 @@ by a digit. '0x' is a hexadecimal number.
case 48: // '0'
- if (next === 120 || next === 88) return readHexNumber();Anything else beginning with a digit is an integer, octal + case 63: ++tokPos; return finishToken(_question);
'0x' is a hexadecimal number.
case 48: // '0'
+ if (next === 120 || next === 88) return readHexNumber();Anything else beginning with a digit is an integer, octal number, or float.
case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
- return readNumber(String.fromCharCode(code));Quotes produce strings.
case 34: case 39: // '"', "'"
- return readString(String.fromCharCode(code));Operators are parsed inline in tiny state machines. '=' (61) is + return readNumber(String.fromCharCode(code));
Quotes produce strings.
case 34: case 39: // '"', "'"
+ return readString(String.fromCharCode(code));Operators are parsed inline in tiny state machines. '=' (61) is
often referred to. finishOp simply skips the amount of
characters it is given as second argument, and returns a token
of the type given by its first argument.
case 47: // '/'
@@ -347,7 +344,7 @@ of the type given by its first argument. If we are here, we either found a non-ASCII identifier + }
If we are here, we either found a non-ASCII identifier character, or something that's entirely disallowed.
var ch = String.fromCharCode(code);
if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord();
raise(tokPos, "Unexpected character '" + ch + "'");
@@ -357,7 +354,7 @@ character, or something that's entirely disallowed. Parse a regular expression. Some context-awareness is necessary, + }
Parse a regular expression. Some context-awareness is necessary, since a '/' inside a '[]' set does not end the expression.
function readRegexp() {
var content = "", escaped, inClass, start = tokPos;
for (;;) {
@@ -373,11 +370,11 @@ since a '/' inside a '[]' set does not end the expression. Need to use readWord1 because '\uXXXX' sequences are allowed
+ ++tokPos;
Need to use readWord1 because '\uXXXX' sequences are allowed
here (don't ask).
var mods = readWord1();
if (mods && !/^[gmsiy]*$/.test(mods)) raise(start, "Invalid regexp flag");
return finishToken(_regexp, new RegExp(content, mods));
- }Read an integer in the given radix. Return null if zero digits + }
Read an integer in the given radix. Return null if zero digits
were read, the integer value otherwise. When len is given, this
will return null unless the integer has exactly len digits.
function readInt(radix, len) {
var start = tokPos, total = 0;
@@ -402,7 +399,7 @@ will return null unless the integer has exactly len di
if (val == null) raise(tokStart + 2, "Expected hexadecimal number");
if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
return finishToken(_num, val);
- }Read an integer, octal integer, or floating-point number.
+ }Read an integer, octal integer, or floating-point number.
function readNumber(ch) {
var start = tokPos, isFloat = ch === ".";
if (!isFloat && readInt(10) == null) raise(start, "Invalid number");
@@ -426,7 +423,7 @@ will return null unless the integer has exactly len di
else if (/[89]/.test(str) || strict) raise(start, "Invalid number");
else val = parseInt(str, 8);
return finishToken(_num, val);
- }Read a string value, interpreting backslash-escapes.
function readString(quote) {
+ }Read a string value, interpreting backslash-escapes.
function readString(quote) {
tokPos++;
var str = "";
for (;;) {
@@ -472,13 +469,13 @@ will return null unless the integer has exactly len di
++tokPos;
}
}
- }Used to read character escape sequences ('\x', '\u', '\U').
function readHexChar(len) {
+ }Used to read character escape sequences ('\x', '\u', '\U').
function readHexChar(len) {
var n = readInt(16, len);
if (n === null) raise(tokStart, "Bad character escape sequence");
return String.fromCharCode(n);
- }Used to signal to callers of readWord1 whether the word
+ }
Used to signal to callers of readWord1 whether the word
contained any escape sequences. This is needed because words with
-escape sequences must not be interpreted as keywords.
var containsEsc;Read an identifier, and return it as a string. Sets containsEsc
+escape sequences must not be interpreted as keywords.
var containsEsc;Read an identifier, and return it as a string. Sets containsEsc
to whether the word contained a '\u' escape.
Only builds up the word character-by-character when it actually @@ -507,7 +504,7 @@ containeds an escape, as a micro-optimization.
Read an identifier or keyword token. Will check for reserved + }
Read an identifier or keyword token. Will check for reserved words when necessary.
function readWord() {
var word = readWord1();
var type = _name;
@@ -519,7 +516,7 @@ words when necessary. A recursive descent parser operates by defining functions for all + }
A recursive descent parser operates by defining functions for all
syntactic elements, and recursively calling those, each function
advancing the input stream and returning an AST node. Precedence
of constructs (for example, the fact that !x[1] means !(x[1])
@@ -533,26 +530,29 @@ way, it'll receive the node for x[1] already parsed, and wraps
operator precedence, because it is much more compact than using
the technique outlined above, which uses different, nesting
functions to specify precedence, for all of the ten binary
-precedence levels that JavaScript defines.
Continue to the next token.
+precedence levels that JavaScript defines. Continue to the next token.
function next() {
lastStart = tokStart;
lastEnd = tokEnd;
+ lastEndLoc = tokEndLoc;
readToken();
- }Enter strict mode. Re-reads the next token to please pedantic + }
Enter strict mode. Re-reads the next token to please pedantic tests ("use strict"; 010; -- should fail).
function setStrict(strct) {
strict = strct;
- tokPos = options.linePositions ? lastEnd.offset : lastEnd;
+ tokPos = lastEnd;
skipSpace();
readToken();
- }Start an AST node, attaching a start offset and optionally a + }
Start an AST node, attaching a start offset and optionally a
commentsBefore property to it.
function startNode() {
var node = {type: null, start: tokStart, end: null};
if (options.trackComments && tokCommentsBefore) {
node.commentsBefore = tokCommentsBefore;
tokCommentsBefore = null;
}
+ if (options.locations)
+ node.loc = {start: tokStartLoc, end: null};
return node;
- }Start a node whose start offset/comments information should be + }
Start a node whose start offset/comments information should be based on the start of another node. For example, a binary operator node is only started after its left-hand side has already been parsed.
function startNodeFrom(other) {
@@ -561,8 +561,11 @@ already been parsed. Finish an AST node, adding type, end, and commentsAfter
+ }
Finish an AST node, adding type, end, and commentsAfter
properties.
We keep track of the last node that we finished, in order @@ -583,40 +586,42 @@ operator node, not the second literal node.
Test whether a statement node is the string literal "use strict".
function isUseStrict(stmt) {
+ }Test whether a statement node is the string literal "use strict".
function isUseStrict(stmt) {
return options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
- }Predicate that tests whether the next token is of the given + }
Predicate that tests whether the next token is of the given type, and if yes, consumes it as a side effect.
function eat(type) {
if (tokType === type) {
next();
return true;
}
- }Test whether a semicolon can be inserted at the current position.
function canInsertSemicolon() {
+ }Test whether a semicolon can be inserted at the current position.
function canInsertSemicolon() {
return tokType === _eof || tokType === _braceR ||
!options.strictSemicolons &&
- newline.test(options.linePositions ? input.slice(lastEnd.offset, tokStart.offset)
- : input.slice(lastEnd, tokStart));
- }Consume a semicolon, or, failing that, see if we are allowed to + newline.test(input.slice(lastEnd, tokStart)); + }
Consume a semicolon, or, failing that, see if we are allowed to pretend that there is a semicolon at this position.
function semicolon() {
if (!eat(_semi) && !canInsertSemicolon()) unexpected();
- }Expect a token of a given type. If found, consume it, otherwise, + }
Expect a token of a given type. If found, consume it, otherwise, raise an unexpected token error.
function expect(type) {
if (tokType === type) next();
else unexpected();
- }Raise an unexpected token error.
function unexpected() {
+ }Raise an unexpected token error.
function unexpected() {
raise(tokStart, "Unexpected token");
- }Verify that a node is an lval — something that can be assigned + }
Verify that a node is an lval — something that can be assigned to.
function checkLVal(expr) {
if (expr.type !== "Identifier" && expr.type !== "MemberExpression")
raise(expr.start, "Assigning to rvalue");
if (strict && expr.type === "Identifier" && isStrictBadIdWord(expr.name))
raise(expr.start, "Assigning to " + expr.name + " in strict mode");
- }Parse a program. Initializes the parser, reads any number of + }
Parse a program. Initializes the parser, reads any number of statements, and wraps them in a Program node.
function parseTopLevel() {
initTokenState();
- lastStart = lastEnd = options.linePositions ? curLinePos() : tokPos;
+ lastStart = lastEnd = tokPos;
+ if (options.locations) lastEndLoc = curLineLoc();
inFunction = strict = null;
labels = [];
readToken();
@@ -632,7 +637,7 @@ statements, and wraps them in a Program node. Parse a single statement.
+ var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};Parse a single statement.
If expecting a statement and finding a slash operator, parse a regular expression literal. This is to handle cases like @@ -641,7 +646,7 @@ does not help.
Most types of statements are recognized by the keyword they + var starttype = tokType, node = startNode();
Most types of statements are recognized by the keyword they start with. Many are trivial to parse, some require a bit of complexity.
switch (starttype) {
case _break: case _continue:
@@ -652,7 +657,7 @@ complexity. Verify that there is an actual destination to break or + }
Verify that there is an actual destination to break or continue to.
for (var i = 0; i < labels.length; ++i) {
var lab = labels[i];
if ((node.label == null || lab.name === node.label.name) &&
@@ -672,7 +677,7 @@ continue to. Disambiguating between a for and a for/in loop is
+ return finishNode(node, "DoWhileStatement");
Disambiguating between a for and a for/in loop is
non-trivial. Basically, we have to parse the init var
statement or expression, disallowing the in operator (see
the second parameter to parseExpression), and then check
@@ -708,7 +713,7 @@ a regular for loop.
In return (and break/continue), the keywords with
+ next();
In return (and break/continue), the keywords with
optional arguments, we eagerly look for a semicolon or the
possibility to insert one.
if (eat(_semi) || canInsertSemicolon()) node.argument = null;
@@ -720,7 +725,7 @@ possibility to insert one. Statements under must be grouped (by label) in SwitchCase + labels.push(switchLabel);
Statements under must be grouped (by label) in SwitchCase
nodes. cur is used to keep the node that we are currently
adding statements to.
for (var cur, sawDefault; tokType != _braceR;) {
@@ -798,7 +803,7 @@ adding statements to. If the statement does not start with a statement keyword or a + return finishNode(node, "EmptyStatement");
If the statement does not start with a statement keyword or a brace, it's an ExpressionStatement or LabeledStatement. We simply start parsing an expression, and afterwards, if the next token is a colon and the expression was a simple @@ -818,13 +823,13 @@ Identifier node, we switch to interpreting it as a label.
Used for constructs like switch and if that insist on
+ }
Used for constructs like switch and if that insist on
parentheses around their expression.
function parseParenExpression() {
expect(_parenL);
var val = parseExpression();
expect(_parenR);
return val;
- }Parse a semicolon-enclosed block of statements, handling "use
+ }
Parse a semicolon-enclosed block of statements, handling "use
strict" declarations when allowStrict is true (used for
function bodies).
function parseBlock(allowStrict) {
var node = startNode(), first = true, strict = false, oldStrict;
@@ -841,7 +846,7 @@ function bodies). Parse a regular for loop. The disambiguation code in
+ }
Parse a regular for loop. The disambiguation code in
parseStatement will already have parsed the init statement or
expression.
function parseFor(node, init) {
node.init = init;
@@ -853,14 +858,14 @@ expression. Parse a for/in loop.
function parseForIn(node, init) {
+ }Parse a for/in loop.
function parseForIn(node, init) {
node.left = init;
node.right = parseExpression();
expect(_parenR);
node.body = parseStatement();
labels.pop();
return finishNode(node, "ForInStatement");
- }Parse a list of variable declarations.
function parseVar(node, noIn) {
+ }Parse a list of variable declarations.
function parseVar(node, noIn) {
node.declarations = [];
node.kind = "var";
for (;;) {
@@ -873,11 +878,11 @@ expression. These nest, from the most general expression type at the top to + }
These nest, from the most general expression type at the top to 'atomic', nondivisible expression types at the bottom. Most of the functions will simply let the function(s) below them parse, and, if the syntactic construct they handle is present, wrap -the AST node that the inner parser gave them in another node.
Parse a full expression. The arguments are used to forbid comma +the AST node that the inner parser gave them in another node.
Parse a full expression. The arguments are used to forbid comma
sequences (in argument lists, array literals, or object literals)
or the in operator (in for loops initalization expressions).
function parseExpression(noComma, noIn) {
var expr = parseMaybeAssign(noIn);
@@ -888,7 +893,7 @@ or the in operator (in for loops initalization expressions).
return finishNode(node, "SequenceExpression");
}
return expr;
- }Parse an assignment expression. This includes applications of + }
Parse an assignment expression. This includes applications of
operators like +=.
function parseMaybeAssign(noIn) {
var left = parseMaybeConditional(noIn);
if (tokType.isAssign) {
@@ -901,7 +906,7 @@ operators like +=. Parse a ternary conditional (?:) operator.
function parseMaybeConditional(noIn) {
+ }Parse a ternary conditional (?:) operator.
function parseMaybeConditional(noIn) {
var expr = parseExprOps(noIn);
if (eat(_question)) {
var node = startNodeFrom(expr);
@@ -912,9 +917,9 @@ operators like +=. Start the precedence parser.
function parseExprOps(noIn) {
+ }Start the precedence parser.
function parseExprOps(noIn) {
return parseExprOp(parseMaybeUnary(noIn), -1, noIn);
- }Parse binary operators with the operator precedence parsing + }
Parse binary operators with the operator precedence parsing
algorithm. left is the left-hand side of the operator.
minPrec provides context that allows the function to stop and
defer further parser to one of its callers when it encounters an
@@ -932,7 +937,7 @@ operator that has a lower precedence than the set it is parsing.
Parse unary operators, both prefix and postfix.
function parseMaybeUnary(noIn) {
+ }Parse unary operators, both prefix and postfix.
function parseMaybeUnary(noIn) {
if (tokType.prefix) {
var node = startNode(), update = tokType.isUpdate;
node.operator = tokVal;
@@ -956,7 +961,7 @@ operator that has a lower precedence than the set it is parsing.
expr = finishNode(node, "UpdateExpression");
}
return expr;
- }Parse call, dot, and []-subscript expressions.
function parseExprSubscripts() {
+ }Parse call, dot, and []-subscript expressions.
function parseExprSubscripts() {
return parseSubscripts(parseExprAtom());
}
@@ -980,7 +985,7 @@ operator that has a lower precedence than the set it is parsing.
node.arguments = parseExprList(_parenR, false);
return parseSubscripts(finishNode(node, "CallExpression"), noCalls);
} else return base;
- }Parse an atomic expression — either a single token that is an + }
Parse an atomic expression — either a single token that is an
expression, an expression started by a keyword like function or
new, or an expression wrapped in punctuation like (), [],
or {}.
function parseExprAtom() {
@@ -1030,7 +1035,7 @@ or {}. New's precedence is slightly tricky. It must allow its argument + }
New's precedence is slightly tricky. It must allow its argument
to be a [] or dot subscript expression, but not a call — at
least, not without wrapping it in parentheses. Thus, it uses the
function parseNew() {
var node = startNode();
@@ -1039,7 +1044,7 @@ least, not without wrapping it in parentheses. Thus, it uses the
if (eat(_parenL)) node.arguments = parseExprList(_parenR, false);
else node.arguments = [];
return finishNode(node, "NewExpression");
- }Parse an object literal.
function parseObj() {
+ }Parse an object literal.
function parseObj() {
var node = startNode(), first = true, sawGetSet = false;
node.properties = [];
next();
@@ -1060,7 +1065,7 @@ least, not without wrapping it in parentheses. Thus, it uses the
prop.key = parsePropertyName();
if (!tokType === _parenL) unexpected();
prop.value = parseFunction(startNode(), false);
- } else unexpected();getters and setters are not allowed to clash — either with + } else unexpected();
getters and setters are not allowed to clash — either with each other or with an init property — and in strict mode, init properties are also not allowed to be repeated.
if (prop.key.type === "Identifier" && (strict || sawGetSet)) {
for (var i = 0; i < node.properties.length; ++i) {
@@ -1081,7 +1086,7 @@ init properties are also not allowed to be repeated. Parse a function declaration or literal (depending on the + }
Parse a function declaration or literal (depending on the
isStatement parameter).
function parseFunction(node, isStatement) {
if (tokType === _name) node.id = parseIdent();
else if (isStatement) unexpected();
@@ -1092,11 +1097,11 @@ init properties are also not allowed to be repeated. Start a new scope with regard to labels and the inFunction
+ }
Start a new scope with regard to labels and the inFunction
flag (restore them to their old value afterwards).
var oldInFunc = inFunction, oldLabels = labels;
inFunction = true; labels = [];
node.body = parseBlock(true);
- inFunction = oldInFunc; labels = oldLabels;If this is a strict mode function, verify that argument names + inFunction = oldInFunc; labels = oldLabels;
If this is a strict mode function, verify that argument names
are not repeated, and it does not try to bind the words eval
or arguments.
if (strict || node.body.body.length && isUseStrict(node.body.body[0])) {
for (var i = node.id ? -1 : 0; i < node.params.length; ++i) {
@@ -1109,7 +1114,7 @@ or arguments. Parses a comma-separated list of expressions, and returns them as + }
Parses a comma-separated list of expressions, and returns them as
an array. close is the token type that ends the list, and
allowEmpty can be turned on to allow subsequent commas with
nothing in between them to be parsed as null (which is needed
@@ -1125,7 +1130,7 @@ for array literals).
Parse the next token as an identifier. If liberal is true (used
+ }
Parse the next token as an identifier. If liberal is true (used
when parsing properties), it will also convert keywords into
identifiers.
function parseIdent(liberal) {
var node = startNode();
diff --git a/test/driver.js b/test/driver.js
index 78cc8e4328..285461f076 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -10,7 +10,7 @@
};
exports.runTests = function(callback) {
- var opts = {linePositions: true};
+ var opts = {locations: true};
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
try {
@@ -58,4 +58,27 @@
}
}
}
+
+ function mangle(ast) {
+ if (typeof ast != "object" || !ast) return;
+ if (ast.slice) {
+ for (var i = 0; i < ast.length; ++i) mangle(ast[i]);
+ } else {
+ var loc = ast.start && ast.end && {start: ast.start, end: ast.end};
+ if (loc) { delete ast.start; delete ast.end; }
+ for (var name in ast) if (ast.hasOwnProperty(name)) mangle(ast[name]);
+ if (loc) ast.loc = loc;
+ }
+ }
+
+ exports.printTests = function() {
+ var out = "";
+ for (var i = 0; i < tests.length; ++i) {
+ if (tests[i].error) continue;
+ mangle(tests[i].ast);
+ out += "test(" + JSON.stringify(tests[i].code) + ", " + JSON.stringify(tests[i].ast, null, 2) + ");\n\n";
+ }
+ document.body.innerHTML = "";
+ document.body.appendChild(document.createElement("pre")).appendChild(document.createTextNode(out));
+ };
})(typeof exports == "undefined" ? window : exports);
diff --git a/test/tests.js b/test/tests.js
index 096048263a..83ff7ec823 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -8,11358 +8,25720 @@ if (typeof exports != "undefined") {
test("this\n", {
type: "Program",
- start: {
- line: 1,
- column: 0
- },
body: [
{
type: "ExpressionStatement",
- start: {
- line: 1,
- column: 0
- },
expression: {
type: "ThisExpression",
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("null\n", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: null,
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("\n 42\n\n", {
type: "Program",
- start: {line: 2, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 4},
expression: {
type: "Literal",
- start: {line: 2, column: 4},
value: 42,
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("(1 + 2 ) * 3", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 1},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 1},
left: {
type: "Literal",
- start: {line: 1, column: 1},
value: 1,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
operator: "+",
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 2,
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "*",
right: {
type: "Literal",
- start: {line: 1, column: 11},
value: 3,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
}
],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
});
test("x = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x = [ ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x = [ 42 ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [
{
type: "Literal",
- start: {line: 1, column: 6},
value: 42,
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
});
test("x = [ 42, ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [
{
type: "Literal",
- start: {line: 1, column: 6},
value: 42,
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("x = [ ,, 42 ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [
null,
null,
{
type: "Literal",
- start: {line: 1, column: 9},
value: 42,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("x = [ 1, 2, 3, ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [
{
type: "Literal",
- start: {line: 1, column: 6},
value: 1,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
{
type: "Literal",
- start: {line: 1, column: 9},
value: 2,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
{
type: "Literal",
- start: {line: 1, column: 12},
value: 3,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("x = [ 1, 2,, 3, ]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 4},
elements: [
{
type: "Literal",
- start: {line: 1, column: 6},
value: 1,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
{
type: "Literal",
- start: {line: 1, column: 9},
value: 2,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
null,
{
type: "Literal",
- start: {line: 1, column: 13},
value: 3,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("日本語 = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "日本語",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 6},
elements: [],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("T‿ = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "T‿",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 5},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("T = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "T",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 5},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("T = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "T",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 5},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("ⅣⅡ = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "ⅣⅡ",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 5},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("ⅣⅡ = []", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "ⅣⅡ",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
right: {
type: "ArrayExpression",
- start: {line: 1, column: 5},
elements: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x = {}", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x = { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x = { answer: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "answer",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 14},
value: 42,
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
});
test("x = { if: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "if",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 10},
value: 42,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("x = { true: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "true",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 12},
value: 42,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("x = { false: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "false",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 13},
value: 42,
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("x = { null: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "null",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 12},
value: 42,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("x = { \"answer\": 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Literal",
- start: {line: 1, column: 6},
value: "answer",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 16},
value: 42,
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
});
test("x = { x: 1, x: 2 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 9},
value: 1,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
kind: "init"
},
{
key: {
type: "Identifier",
- start: {line: 1, column: 12},
name: "x",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 15},
value: 2,
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
});
test("x = { get width() { return m_width } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "width",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 15},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 20},
argument: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "m_width",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
});
test("x = { get undef() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "undef",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 15},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("x = { get if() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "if",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 12},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 15},
body: [],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
});
test("x = { get true() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "true",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 14},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 17},
body: [],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("x = { get false() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "false",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 15},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("x = { get null() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "null",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 14},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 17},
body: [],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("x = { get \"undef\"() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Literal",
- start: {line: 1, column: 10},
value: "undef",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 17},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 20},
body: [],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("x = { get 10() {} }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Literal",
- start: {line: 1, column: 10},
value: 10,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
kind: "get",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 12},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 15},
body: [],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
});
test("x = { set width(w) { m_width = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "width",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 15},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 16},
name: "w",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 21},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 21},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 21},
name: "m_width",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 31},
name: "w",
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 31
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
});
test("x = { set if(w) { m_if = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "if",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 12},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 13},
name: "w",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 16},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 18},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 18},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "m_if",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 25},
name: "w",
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
});
test("x = { set true(w) { m_true = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "true",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 14},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 15},
name: "w",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 20},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "m_true",
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 29},
name: "w",
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 29
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("x = { set false(w) { m_false = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "false",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 15},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 16},
name: "w",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 21},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 21},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 21},
name: "m_false",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 31},
name: "w",
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 31
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
});
test("x = { set null(w) { m_null = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "null",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 14},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 15},
name: "w",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 20},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "m_null",
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 29},
name: "w",
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 29
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("x = { set \"null\"(w) { m_null = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Literal",
- start: {line: 1, column: 10},
value: "null",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 16},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 17},
name: "w",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 20},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 22},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 22},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 22},
name: "m_null",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 31},
name: "w",
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 31
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
});
test("x = { set 10(w) { m_null = w } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Literal",
- start: {line: 1, column: 10},
value: 10,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
kind: "set",
value: {
type: "FunctionExpression",
- start: {line: 1, column: 12},
id: null,
params: [
{
type: "Identifier",
- start: {line: 1, column: 13},
name: "w",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 16},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 18},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 18},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "m_null",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "w",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
});
test("x = { get: 42 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "get",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 11},
value: 42,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
});
test("x = { set: 43 }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "ObjectExpression",
- start: {line: 1, column: 4},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "set",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 11},
value: 43,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
});
test("/* block comment */ 42", {
type: "Program",
- start: {line: 1, column: 20},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "Literal",
- start: {line: 1, column: 20},
value: 42,
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("42 /*The*/ /*Answer*/", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 42,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("42 /*the*/ /*answer*/", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 42,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("/* multiline\ncomment\nshould\nbe\nignored */ 42", {
type: "Program",
- start: {line: 5, column: 11},
body: [
{
type: "ExpressionStatement",
- start: {line: 5, column: 11},
expression: {
type: "Literal",
- start: {line: 5, column: 11},
value: 42,
- end: {line: 5, column: 13}
+ loc: {
+ start: {
+ line: 5,
+ column: 11
+ },
+ end: {
+ line: 5,
+ column: 13
+ }
+ }
},
- end: {line: 5, column: 13}
+ loc: {
+ start: {
+ line: 5,
+ column: 11
+ },
+ end: {
+ line: 5,
+ column: 13
+ }
+ }
}
],
- end: {line: 5, column: 13}
+ loc: {
+ start: {
+ line: 5,
+ column: 11
+ },
+ end: {
+ line: 5,
+ column: 13
+ }
+ }
});
test("/*a\r\nb*/ 42", {
type: "Program",
- start: {line: 2, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 4},
expression: {
type: "Literal",
- start: {line: 2, column: 4},
value: 42,
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("/*a\rb*/ 42", {
type: "Program",
- start: {line: 2, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 4},
expression: {
type: "Literal",
- start: {line: 2, column: 4},
value: 42,
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("/*a\nb*/ 42", {
type: "Program",
- start: {line: 2, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 4},
expression: {
type: "Literal",
- start: {line: 2, column: 4},
value: 42,
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("/*a\nc*/ 42", {
type: "Program",
- start: {line: 2, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 4},
expression: {
type: "Literal",
- start: {line: 2, column: 4},
value: 42,
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 4
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("// line comment\n42", {
type: "Program",
- start: {line: 2, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Literal",
- start: {line: 2, column: 0},
value: 42,
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
});
test("42 // line comment", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 42,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("// Hello, world!\n42", {
type: "Program",
- start: {line: 2, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Literal",
- start: {line: 2, column: 0},
value: 42,
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
});
test("// Hello, world!\n", {
type: "Program",
- start: {line: 2, column: 0},
body: [],
- end: {line: 2, column: 0}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 0
+ }
+ }
});
test("// Hallo, world!\n", {
type: "Program",
- start: {line: 2, column: 0},
body: [],
- end: {line: 2, column: 0}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 0
+ }
+ }
});
test("//\n42", {
type: "Program",
- start: {line: 2, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Literal",
- start: {line: 2, column: 0},
value: 42,
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
});
test("//", {
type: "Program",
- start: {line: 1, column: 2},
body: [],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("// ", {
type: "Program",
- start: {line: 1, column: 3},
body: [],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("/**/42", {
type: "Program",
- start: {line: 1, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 4},
expression: {
type: "Literal",
- start: {line: 1, column: 4},
value: 42,
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("// Hello, world!\n\n// Another hello\n42", {
type: "Program",
- start: {line: 4, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 4, column: 0},
expression: {
type: "Literal",
- start: {line: 4, column: 0},
value: 42,
- end: {line: 4, column: 2}
+ loc: {
+ start: {
+ line: 4,
+ column: 0
+ },
+ end: {
+ line: 4,
+ column: 2
+ }
+ }
},
- end: {line: 4, column: 2}
+ loc: {
+ start: {
+ line: 4,
+ column: 0
+ },
+ end: {
+ line: 4,
+ column: 2
+ }
+ }
}
],
- end: {line: 4, column: 2}
+ loc: {
+ start: {
+ line: 4,
+ column: 0
+ },
+ end: {
+ line: 4,
+ column: 2
+ }
+ }
});
test("if (x) { // Some comment\ndoThat(); }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
consequent: {
type: "BlockStatement",
- start: {line: 1, column: 7},
body: [
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "CallExpression",
- start: {line: 2, column: 0},
callee: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "doThat",
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
arguments: [],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
},
- end: {line: 2, column: 9}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 9
+ }
+ }
}
],
- end: {line: 2, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 2,
+ column: 11
+ }
+ }
},
alternate: null,
- end: {line: 2, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 11
+ }
+ }
}
],
- end: {line: 2, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 11
+ }
+ }
});
test("switch (answer) { case 42: /* perfect */ bingo() }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "SwitchStatement",
- start: {line: 1, column: 0},
discriminant: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "answer",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
cases: [
{
type: "SwitchCase",
- start: {line: 1, column: 18},
consequent: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 41},
expression: {
type: "CallExpression",
- start: {line: 1, column: 41},
callee: {
type: "Identifier",
- start: {line: 1, column: 41},
name: "bingo",
- end: {line: 1, column: 46}
+ loc: {
+ start: {
+ line: 1,
+ column: 41
+ },
+ end: {
+ line: 1,
+ column: 46
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 48}
+ loc: {
+ start: {
+ line: 1,
+ column: 41
+ },
+ end: {
+ line: 1,
+ column: 48
+ }
+ }
},
- end: {line: 1, column: 48}
+ loc: {
+ start: {
+ line: 1,
+ column: 41
+ },
+ end: {
+ line: 1,
+ column: 48
+ }
+ }
}
],
test: {
type: "Literal",
- start: {line: 1, column: 23},
value: 42,
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 48}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 48
+ }
+ }
}
],
- end: {line: 1, column: 50}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 50
+ }
+ }
}
],
- end: {line: 1, column: 50}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 50
+ }
+ }
});
test("0", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 0,
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
}
],
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
});
test("3", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 3,
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
}
],
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
});
test("5", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 5,
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
}
],
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
});
test("42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 42,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test(".14", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 0.14,
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("3.14159", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 3.14159,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("6.02214179e+23", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 6.02214179e+23,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("1.492417830e-10", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 1.49241783e-10,
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
});
test("0x0", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 0,
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("0e+100", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 0,
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("0xabc", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 2748,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("0xdef", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 3567,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("0X1A", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 26,
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("0x10", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 16,
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("0x100", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 256,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("0X04", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 4,
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("02", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 2,
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("012", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 10,
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("0012", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: 10,
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("\"Hello\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("\"\\n\\r\\t\\v\\b\\f\\\\\\'\\\"\\0\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "\n\r\t\u000b\b\f\\'\"\u0000",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("\"\\u0061\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "a",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("\"\\x61\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "a",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("\"Hello\\nworld\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\nworld",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("\"Hello\\\nworld\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Helloworld",
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("\"Hello\\02World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\u0002World",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
});
test("\"Hello\\012World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\nWorld",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\122World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "HelloRWorld",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\0122World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\n2World",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("\"Hello\\312World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "HelloÊWorld",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\412World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello!2World",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\812World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello812World",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\712World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello92World",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("\"Hello\\0World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\u0000World",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("\"Hello\\\r\nworld\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Helloworld",
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
});
test("\"Hello\\1World\"", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Literal",
- start: {line: 1, column: 0},
value: "Hello\u0001World",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("var x = /[a-z]/i", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("var x = /[x-z]/i", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("var x = /[a-c]/i", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("var x = /[P QR]/i", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("var x = /foo\\/bar/", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
});
test("var x = /=([^=\\s])+/g", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("var x = /[P QR]/\\u0067", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: {},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("new Button", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "Button",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
});
test("new Button()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "Button",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
}
],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
});
test("new new foo", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "NewExpression",
- start: {line: 1, column: 4},
callee: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "foo",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("new new foo()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "NewExpression",
- start: {line: 1, column: 4},
callee: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "foo",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("new foo().bar()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "foo",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "bar",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
computed: false,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
});
test("new foo[bar]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 4},
object: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "foo",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "bar",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
computed: true,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
}
],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
});
test("new foo.bar()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "NewExpression",
- start: {line: 1, column: 0},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 4},
object: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "foo",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "bar",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
computed: false,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("( new foo).bar()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "CallExpression",
- start: {line: 1, column: 2},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 2},
object: {
type: "NewExpression",
- start: {line: 1, column: 2},
callee: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "foo",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "bar",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
computed: false,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
});
test("foo(bar, baz)", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "foo",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 4},
name: "bar",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 9},
name: "baz",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("( foo )()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "CallExpression",
- start: {line: 1, column: 5},
callee: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "foo",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("universe.milkyway", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "milkyway",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
computed: false,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("universe.milkyway.solarsystem", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "milkyway",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
computed: false,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "solarsystem",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
computed: false,
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
});
test("universe.milkyway.solarsystem.Earth", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "milkyway",
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
computed: false,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "solarsystem",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
computed: false,
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 30},
name: "Earth",
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
computed: false,
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
});
test("universe[galaxyName, otherUselessName]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "SequenceExpression",
- start: {line: 1, column: 9},
expressions: [
{
type: "Identifier",
- start: {line: 1, column: 9},
name: "galaxyName",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 21},
name: "otherUselessName",
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
}
],
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
},
computed: true,
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
});
test("universe[galaxyName]", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "galaxyName",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
computed: true,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
});
test("universe[42].galaxies", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Literal",
- start: {line: 1, column: 9},
value: 42,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
computed: true,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "galaxies",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
computed: false,
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("universe(42).galaxies", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
arguments: [
{
type: "Literal",
- start: {line: 1, column: 9},
value: 42,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "galaxies",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
computed: false,
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("universe(42).galaxies(14, 3, 77).milkyway", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
arguments: [
{
type: "Literal",
- start: {line: 1, column: 9},
value: 42,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "galaxies",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
computed: false,
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
arguments: [
{
type: "Literal",
- start: {line: 1, column: 22},
value: 14,
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
{
type: "Literal",
- start: {line: 1, column: 26},
value: 3,
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
{
type: "Literal",
- start: {line: 1, column: 29},
value: 77,
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 29
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 33},
name: "milkyway",
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
},
computed: false,
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
},
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
}
],
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
});
test("earth.asia.Indonesia.prepareForElection(2014)", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "CallExpression",
- start: {line: 1, column: 0},
callee: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "earth",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "asia",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
computed: false,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "Indonesia",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
computed: false,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 21},
name: "prepareForElection",
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
},
computed: false,
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
},
arguments: [
{
type: "Literal",
- start: {line: 1, column: 40},
value: 2014,
- end: {line: 1, column: 44}
+ loc: {
+ start: {
+ line: 1,
+ column: 40
+ },
+ end: {
+ line: 1,
+ column: 44
+ }
+ }
}
],
- end: {line: 1, column: 45}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 45
+ }
+ }
},
- end: {line: 1, column: 45}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 45
+ }
+ }
}
],
- end: {line: 1, column: 45}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 45
+ }
+ }
});
test("universe.if", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "if",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
computed: false,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("universe.true", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "true",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
computed: false,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("universe.false", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "false",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
computed: false,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("universe.null", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "MemberExpression",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "universe",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
property: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "null",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
computed: false,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("x++", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("x--", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("eval++", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "eval",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("eval--", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "eval",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("arguments++", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "arguments",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("arguments--", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "arguments",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("++x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "x",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("--x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "x",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
}
],
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
});
test("++eval", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "eval",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("--eval", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "eval",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("++arguments", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "++",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "arguments",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("--arguments", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 0},
operator: "--",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "arguments",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("+x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "+",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 1},
name: "x",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("-x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "-",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 1},
name: "x",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("~x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "~",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 1},
name: "x",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("!x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "!",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 1},
name: "x",
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
},
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("void x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "void",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "x",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("delete x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "delete",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 7},
name: "x",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("typeof x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "UnaryExpression",
- start: {line: 1, column: 0},
operator: "typeof",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 1, column: 7},
name: "x",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("x * y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x / y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "/",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x % y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "%",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x + y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "+",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x - y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "-",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x << y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "<<",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x >> y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: ">>",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x >>> y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: ">>>",
right: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "y",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x < y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "<",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x > y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: ">",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x <= y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "<=",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x >= y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: ">=",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x in y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "in",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x instanceof y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "instanceof",
right: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "y",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("x < y < z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "<",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "<",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x == y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "==",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x != y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "!=",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x === y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "===",
right: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "y",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x !== y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "!==",
right: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "y",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x & y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x ^ y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "^",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x | y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "|",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("x + y + z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "+",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "+",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x - y + z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "-",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "+",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x + y - z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "+",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "-",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x - y - z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "-",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "-",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x + y * z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "+",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 4},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x + y / z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "+",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 4},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "/",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x - y % z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "-",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 4},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "%",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x * y * z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x * y / z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "/",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x * y % z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "%",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x % y * z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "%",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x << y << z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "<<",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "<<",
right: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "z",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("x | y | z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "|",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "|",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x & y & z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "&",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x ^ y ^ z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "^",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "^",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x & y | z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&",
right: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "|",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x | y ^ z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "|",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 4},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "^",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x | y & z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "BinaryExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "|",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 4},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "y",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
operator: "&",
right: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "z",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x || y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "||",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x && y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&&",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("x || y || z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "||",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "||",
right: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "z",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("x && y && z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&&",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "&&",
right: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "z",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("x || y && z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "||",
right: {
type: "LogicalExpression",
- start: {line: 1, column: 5},
left: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "&&",
right: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "z",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("x || y ^ z", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "||",
right: {
type: "BinaryExpression",
- start: {line: 1, column: 5},
left: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
operator: "^",
right: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "z",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
});
test("y ? 1 : 2", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "ConditionalExpression",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "y",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
consequent: {
type: "Literal",
- start: {line: 1, column: 4},
value: 1,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
alternate: {
type: "Literal",
- start: {line: 1, column: 8},
value: 2,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x && y ? 1 : 2", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "ConditionalExpression",
- start: {line: 1, column: 0},
test: {
type: "LogicalExpression",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
operator: "&&",
right: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "y",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
consequent: {
type: "Literal",
- start: {line: 1, column: 9},
value: 1,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
alternate: {
type: "Literal",
- start: {line: 1, column: 13},
value: 2,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("x = 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 4},
value: 42,
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("eval = 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "eval",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 7},
value: 42,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("arguments = 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "arguments",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 12},
value: 42,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("x *= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "*=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x /= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "/=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x %= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "%=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x += 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "+=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x -= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "-=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x <<= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "<<=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 6},
value: 42,
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("x >>= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: ">>=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 6},
value: 42,
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("x >>>= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: ">>>=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 7},
value: 42,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("x &= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "&=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x ^= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "^=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("x |= 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 0},
operator: "|=",
left: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 5},
value: 42,
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("{ foo }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 2},
expression: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "foo",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("{ doThis(); doThat(); }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 2},
expression: {
type: "CallExpression",
- start: {line: 1, column: 2},
callee: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "doThis",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 1, column: 12},
expression: {
type: "CallExpression",
- start: {line: 1, column: 12},
callee: {
type: "Identifier",
- start: {line: 1, column: 12},
name: "doThat",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
});
test("{}", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
}
],
- end: {line: 1, column: 2}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 2
+ }
+ }
});
test("var x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: null,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
});
test("var x, y;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: null,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 7},
id: {
type: "Identifier",
- start: {line: 1, column: 7},
name: "y",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
init: null,
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("var x = 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: 42,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
});
test("var eval = 42, arguments = 42", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "eval",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 11},
value: 42,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 15},
id: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "arguments",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 27},
value: 42,
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
});
test("var x = 14, y = 3, z = 1977", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 8},
value: 14,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 12},
id: {
type: "Identifier",
- start: {line: 1, column: 12},
name: "y",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 16},
value: 3,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 19},
id: {
type: "Identifier",
- start: {line: 1, column: 19},
name: "z",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 23},
value: 1977,
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
});
test("var implements, interface, package", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "implements",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
init: null,
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 16},
id: {
type: "Identifier",
- start: {line: 1, column: 16},
name: "interface",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
init: null,
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 27},
id: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "package",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
init: null,
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("var private, protected, public, static", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "private",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
init: null,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 13},
id: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "protected",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
init: null,
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 24},
id: {
type: "Identifier",
- start: {line: 1, column: 24},
name: "public",
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
init: null,
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 32},
id: {
type: "Identifier",
- start: {line: 1, column: 32},
name: "static",
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 32
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
init: null,
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 32
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
});
test(";", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "EmptyStatement",
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
}
],
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
});
test("x", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
}
],
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
});
test("x, y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "SequenceExpression",
- start: {line: 1, column: 0},
expressions: [
{
type: "Identifier",
- start: {line: 1, column: 0},
name: "x",
- end: {line: 1, column: 1}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 1
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 3},
name: "y",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
}
],
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
});
test("\\u0061", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "a",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
}
],
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
});
test("a\\u0061", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "aa",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
}
],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
});
test("if (morning) goodMorning()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "morning",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
consequent: {
type: "ExpressionStatement",
- start: {line: 1, column: 13},
expression: {
type: "CallExpression",
- start: {line: 1, column: 13},
callee: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "goodMorning",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
alternate: null,
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
});
test("if (morning) (function(){})", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "morning",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
consequent: {
type: "ExpressionStatement",
- start: {line: 1, column: 13},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 14},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 24},
body: [],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
alternate: null,
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
});
test("if (morning) var x = 0;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "morning",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
consequent: {
type: "VariableDeclaration",
- start: {line: 1, column: 13},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 17},
id: {
type: "Identifier",
- start: {line: 1, column: 17},
name: "x",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 21},
value: 0,
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
alternate: null,
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
});
test("if (morning) function a(){}", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "morning",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
consequent: {
type: "FunctionDeclaration",
- start: {line: 1, column: 13},
id: {
type: "Identifier",
- start: {line: 1, column: 22},
name: "a",
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 25},
body: [],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
alternate: null,
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
});
test("if (morning) goodMorning(); else goodDay()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "IfStatement",
- start: {line: 1, column: 0},
test: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "morning",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
consequent: {
type: "ExpressionStatement",
- start: {line: 1, column: 13},
expression: {
type: "CallExpression",
- start: {line: 1, column: 13},
callee: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "goodMorning",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
alternate: {
type: "ExpressionStatement",
- start: {line: 1, column: 33},
expression: {
type: "CallExpression",
- start: {line: 1, column: 33},
callee: {
type: "Identifier",
- start: {line: 1, column: 33},
name: "goodDay",
- end: {line: 1, column: 40}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 40
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 42}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 42
+ }
+ }
},
- end: {line: 1, column: 42}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 42
+ }
+ }
},
- end: {line: 1, column: 42}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 42
+ }
+ }
}
],
- end: {line: 1, column: 42}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 42
+ }
+ }
});
test("do keep(); while (true)", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "DoWhileStatement",
- start: {line: 1, column: 0},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 3},
expression: {
type: "CallExpression",
- start: {line: 1, column: 3},
callee: {
type: "Identifier",
- start: {line: 1, column: 3},
name: "keep",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
test: {
type: "Literal",
- start: {line: 1, column: 18},
value: true,
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
});
test("do keep(); while (true);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "DoWhileStatement",
- start: {line: 1, column: 0},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 3},
expression: {
type: "CallExpression",
- start: {line: 1, column: 3},
callee: {
type: "Identifier",
- start: {line: 1, column: 3},
name: "keep",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
test: {
type: "Literal",
- start: {line: 1, column: 18},
value: true,
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
{
type: "EmptyStatement",
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("do { x++; y--; } while (x < 10)", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "DoWhileStatement",
- start: {line: 1, column: 0},
body: {
type: "BlockStatement",
- start: {line: 1, column: 3},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 5},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 5},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 5},
name: "x",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 1, column: 10},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 10},
operator: "--",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "y",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
test: {
type: "BinaryExpression",
- start: {line: 1, column: 24},
left: {
type: "Identifier",
- start: {line: 1, column: 24},
name: "x",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
operator: "<",
right: {
type: "Literal",
- start: {line: 1, column: 28},
value: 10,
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
});
test("{ do { } while (false) false }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "DoWhileStatement",
- start: {line: 1, column: 2},
body: {
type: "BlockStatement",
- start: {line: 1, column: 5},
body: [],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
test: {
type: "Literal",
- start: {line: 1, column: 16},
value: false,
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 1, column: 23},
expression: {
type: "Literal",
- start: {line: 1, column: 23},
value: false,
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
});
test("while (true) doSomething()", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 13},
expression: {
type: "CallExpression",
- start: {line: 1, column: 13},
callee: {
type: "Identifier",
- start: {line: 1, column: 13},
name: "doSomething",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
});
test("while (x < 10) { x++; y--; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "BinaryExpression",
- start: {line: 1, column: 7},
left: {
type: "Identifier",
- start: {line: 1, column: 7},
name: "x",
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
operator: "<",
right: {
type: "Literal",
- start: {line: 1, column: 11},
value: 10,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 15},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 17},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 17},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 17},
name: "x",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 1, column: 22},
expression: {
type: "UpdateExpression",
- start: {line: 1, column: 22},
operator: "--",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 22},
name: "y",
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
});
test("for(;;);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: null,
test: null,
update: null,
body: {
type: "EmptyStatement",
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("for(;;){}", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: null,
test: null,
update: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 7},
body: [],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("for(x = 0;;);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "AssignmentExpression",
- start: {line: 1, column: 4},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 8},
value: 0,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
test: null,
update: null,
body: {
type: "EmptyStatement",
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("for(var x = 0;;);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "VariableDeclaration",
- start: {line: 1, column: 4},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 8},
id: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "x",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 12},
value: 0,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
test: null,
update: null,
body: {
type: "EmptyStatement",
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
});
test("for(var x = 0, y = 1;;);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "VariableDeclaration",
- start: {line: 1, column: 4},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 8},
id: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "x",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 12},
value: 0,
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 15},
id: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "y",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 19},
value: 1,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
test: null,
update: null,
body: {
type: "EmptyStatement",
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("for(x = 0; x < 42;);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "AssignmentExpression",
- start: {line: 1, column: 4},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 8},
value: 0,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
test: {
type: "BinaryExpression",
- start: {line: 1, column: 11},
left: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "x",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
operator: "<",
right: {
type: "Literal",
- start: {line: 1, column: 15},
value: 42,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
update: null,
body: {
type: "EmptyStatement",
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
});
test("for(x = 0; x < 42; x++);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "AssignmentExpression",
- start: {line: 1, column: 4},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 8},
value: 0,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
test: {
type: "BinaryExpression",
- start: {line: 1, column: 11},
left: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "x",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
operator: "<",
right: {
type: "Literal",
- start: {line: 1, column: 15},
value: 42,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
update: {
type: "UpdateExpression",
- start: {line: 1, column: 19},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 19},
name: "x",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
body: {
type: "EmptyStatement",
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("for(x = 0; x < 42; x++) process(x);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForStatement",
- start: {line: 1, column: 0},
init: {
type: "AssignmentExpression",
- start: {line: 1, column: 4},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
right: {
type: "Literal",
- start: {line: 1, column: 8},
value: 0,
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
test: {
type: "BinaryExpression",
- start: {line: 1, column: 11},
left: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "x",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
operator: "<",
right: {
type: "Literal",
- start: {line: 1, column: 15},
value: 42,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
update: {
type: "UpdateExpression",
- start: {line: 1, column: 19},
operator: "++",
prefix: false,
argument: {
type: "Identifier",
- start: {line: 1, column: 19},
name: "x",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 24},
expression: {
type: "CallExpression",
- start: {line: 1, column: 24},
callee: {
type: "Identifier",
- start: {line: 1, column: 24},
name: "process",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 32},
name: "x",
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 32
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
});
test("for(x in list) process(x);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForInStatement",
- start: {line: 1, column: 0},
left: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "list",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 15},
expression: {
type: "CallExpression",
- start: {line: 1, column: 15},
callee: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "process",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 23},
name: "x",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
});
test("for (var x in list) process(x);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForInStatement",
- start: {line: 1, column: 0},
left: {
type: "VariableDeclaration",
- start: {line: 1, column: 5},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 9},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "x",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
init: null,
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 14},
name: "list",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "CallExpression",
- start: {line: 1, column: 20},
callee: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "process",
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 28},
name: "x",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
});
test("for (var x = 42 in list) process(x);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForInStatement",
- start: {line: 1, column: 0},
left: {
type: "VariableDeclaration",
- start: {line: 1, column: 5},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 9},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "x",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 13},
value: 42,
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 19},
name: "list",
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 25},
expression: {
type: "CallExpression",
- start: {line: 1, column: 25},
callee: {
type: "Identifier",
- start: {line: 1, column: 25},
name: "process",
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 33},
name: "x",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
});
test("for (var i = function() { return 10 in [] } in list) process(x);", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ForInStatement",
- start: {line: 1, column: 0},
left: {
type: "VariableDeclaration",
- start: {line: 1, column: 5},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 9},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "i",
- end: {line: 1, column: 10}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 10
+ }
+ }
},
init: {
type: "FunctionExpression",
- start: {line: 1, column: 13},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 24},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 26},
argument: {
type: "BinaryExpression",
- start: {line: 1, column: 33},
left: {
type: "Literal",
- start: {line: 1, column: 33},
value: 10,
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
operator: "in",
right: {
type: "ArrayExpression",
- start: {line: 1, column: 39},
elements: [],
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 39
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
},
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
},
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
}
],
- end: {line: 1, column: 43}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 43
+ }
+ }
},
- end: {line: 1, column: 43}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 43
+ }
+ }
},
- end: {line: 1, column: 43}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 43
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 43}
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 43
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 47},
name: "list",
- end: {line: 1, column: 51}
+ loc: {
+ start: {
+ line: 1,
+ column: 47
+ },
+ end: {
+ line: 1,
+ column: 51
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 53},
expression: {
type: "CallExpression",
- start: {line: 1, column: 53},
callee: {
type: "Identifier",
- start: {line: 1, column: 53},
name: "process",
- end: {line: 1, column: 60}
+ loc: {
+ start: {
+ line: 1,
+ column: 53
+ },
+ end: {
+ line: 1,
+ column: 60
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 61},
name: "x",
- end: {line: 1, column: 62}
+ loc: {
+ start: {
+ line: 1,
+ column: 61
+ },
+ end: {
+ line: 1,
+ column: 62
+ }
+ }
}
],
- end: {line: 1, column: 63}
+ loc: {
+ start: {
+ line: 1,
+ column: 53
+ },
+ end: {
+ line: 1,
+ column: 63
+ }
+ }
},
- end: {line: 1, column: 64}
+ loc: {
+ start: {
+ line: 1,
+ column: 53
+ },
+ end: {
+ line: 1,
+ column: 64
+ }
+ }
},
- end: {line: 1, column: 64}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 64
+ }
+ }
}
],
- end: {line: 1, column: 64}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 64
+ }
+ }
});
test("while (true) { continue; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
});
test("while (true) { continue }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
}
],
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
});
test("done: while (true) { continue done }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "WhileStatement",
- start: {line: 1, column: 6},
test: {
type: "Literal",
- start: {line: 1, column: 13},
value: true,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 21},
label: {
type: "Identifier",
- start: {line: 1, column: 30},
name: "done",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "done",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
});
test("done: while (true) { continue done; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "WhileStatement",
- start: {line: 1, column: 6},
test: {
type: "Literal",
- start: {line: 1, column: 13},
value: true,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 21},
label: {
type: "Identifier",
- start: {line: 1, column: 30},
name: "done",
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
},
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "done",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
}
],
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
});
test("while (true) { break }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("done: while (true) { break done }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "WhileStatement",
- start: {line: 1, column: 6},
test: {
type: "Literal",
- start: {line: 1, column: 13},
value: true,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 21},
label: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "done",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "done",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
}
],
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
});
test("done: while (true) { break done; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "WhileStatement",
- start: {line: 1, column: 6},
test: {
type: "Literal",
- start: {line: 1, column: 13},
value: true,
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 19},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 21},
label: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "done",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "done",
- end: {line: 1, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 4
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("(function(){ return })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: null,
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("(function(){ return; })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: null,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
});
test("(function(){ return x; })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "x",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
}
],
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
});
test("(function(){ return x * y })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: {
type: "BinaryExpression",
- start: {line: 1, column: 20},
left: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "x",
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 24},
name: "y",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
}
],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
});
test("with (x) foo = bar", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WithStatement",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 9},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 9},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "foo",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "bar",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
});
test("with (x) foo = bar;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WithStatement",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
body: {
type: "ExpressionStatement",
- start: {line: 1, column: 9},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 9},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "foo",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "bar",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
});
test("with (x) { foo = bar }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WithStatement",
- start: {line: 1, column: 0},
object: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 9},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 11},
expression: {
type: "AssignmentExpression",
- start: {line: 1, column: 11},
operator: "=",
left: {
type: "Identifier",
- start: {line: 1, column: 11},
name: "foo",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
right: {
type: "Identifier",
- start: {line: 1, column: 17},
name: "bar",
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
}
],
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
});
test("switch (x) {}", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "SwitchStatement",
- start: {line: 1, column: 0},
discriminant: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "x",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
cases: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
}
],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
});
test("switch (answer) { case 42: hi(); break; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "SwitchStatement",
- start: {line: 1, column: 0},
discriminant: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "answer",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
cases: [
{
type: "SwitchCase",
- start: {line: 1, column: 18},
consequent: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 27},
expression: {
type: "CallExpression",
- start: {line: 1, column: 27},
callee: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "hi",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
{
type: "BreakStatement",
- start: {line: 1, column: 33},
label: null,
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
}
],
test: {
type: "Literal",
- start: {line: 1, column: 23},
value: 42,
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
}
],
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
}
],
- end: {line: 1, column: 41}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 41
+ }
+ }
});
test("switch (answer) { case 42: hi(); break; default: break }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "SwitchStatement",
- start: {line: 1, column: 0},
discriminant: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "answer",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
cases: [
{
type: "SwitchCase",
- start: {line: 1, column: 18},
consequent: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 27},
expression: {
type: "CallExpression",
- start: {line: 1, column: 27},
callee: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "hi",
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
{
type: "BreakStatement",
- start: {line: 1, column: 33},
label: null,
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 33
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
}
],
test: {
type: "Literal",
- start: {line: 1, column: 23},
value: 42,
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
- end: {line: 1, column: 39}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 39
+ }
+ }
},
{
type: "SwitchCase",
- start: {line: 1, column: 40},
consequent: [
{
type: "BreakStatement",
- start: {line: 1, column: 49},
label: null,
- end: {line: 1, column: 54}
+ loc: {
+ start: {
+ line: 1,
+ column: 49
+ },
+ end: {
+ line: 1,
+ column: 54
+ }
+ }
}
],
test: null,
- end: {line: 1, column: 54}
+ loc: {
+ start: {
+ line: 1,
+ column: 40
+ },
+ end: {
+ line: 1,
+ column: 54
+ }
+ }
}
],
- end: {line: 1, column: 56}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 56
+ }
+ }
}
],
- end: {line: 1, column: 56}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 56
+ }
+ }
});
test("start: for (;;) break start", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "ForStatement",
- start: {line: 1, column: 7},
init: null,
test: null,
update: null,
body: {
type: "BreakStatement",
- start: {line: 1, column: 16},
label: {
type: "Identifier",
- start: {line: 1, column: 22},
name: "start",
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "start",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
});
test("start: while (true) break start", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "LabeledStatement",
- start: {line: 1, column: 0},
body: {
type: "WhileStatement",
- start: {line: 1, column: 7},
test: {
type: "Literal",
- start: {line: 1, column: 14},
value: true,
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
body: {
type: "BreakStatement",
- start: {line: 1, column: 20},
label: {
type: "Identifier",
- start: {line: 1, column: 26},
name: "start",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
label: {
type: "Identifier",
- start: {line: 1, column: 0},
name: "start",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
});
test("throw x;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 0},
argument: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
{
type: "EmptyStatement",
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
}
],
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
});
test("throw x * y", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 0},
argument: {
type: "BinaryExpression",
- start: {line: 1, column: 6},
left: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
operator: "*",
right: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "y",
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
}
],
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
});
test("throw { message: \"Error\" }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 0},
argument: {
type: "ObjectExpression",
- start: {line: 1, column: 6},
properties: [
{
key: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "message",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
value: {
type: "Literal",
- start: {line: 1, column: 17},
value: "Error",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
kind: "init"
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
});
test("try { } catch (e) { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 8},
param: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "e",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
},
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
finalizer: null,
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
}
],
- end: {line: 1, column: 21}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 21
+ }
+ }
});
test("try { } catch (eval) { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 8},
param: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "eval",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 21},
body: [],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
finalizer: null,
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("try { } catch (arguments) { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 8},
param: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "arguments",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 26},
body: [],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
finalizer: null,
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
});
test("try { } catch (e) { say(e) }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 8},
param: {
type: "Identifier",
- start: {line: 1, column: 15},
name: "e",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "CallExpression",
- start: {line: 1, column: 20},
callee: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "say",
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 24},
name: "e",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 24
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
}
],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
finalizer: null,
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
});
test("try { } finally { cleanup(stuff) }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [],
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
handlers: [],
finalizer: {
type: "BlockStatement",
- start: {line: 1, column: 16},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 18},
expression: {
type: "CallExpression",
- start: {line: 1, column: 18},
callee: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "cleanup",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 26},
name: "stuff",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
},
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("try { doThat(); } catch (e) { say(e) }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 6},
expression: {
type: "CallExpression",
- start: {line: 1, column: 6},
callee: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "doThat",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 18},
param: {
type: "Identifier",
- start: {line: 1, column: 25},
name: "e",
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 28},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 30},
expression: {
type: "CallExpression",
- start: {line: 1, column: 30},
callee: {
type: "Identifier",
- start: {line: 1, column: 30},
name: "say",
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 34},
name: "e",
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 34
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
finalizer: null,
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
});
test("try { doThat(); } catch (e) { say(e) } finally { cleanup(stuff) }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "TryStatement",
- start: {line: 1, column: 0},
block: {
type: "BlockStatement",
- start: {line: 1, column: 4},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 6},
expression: {
type: "CallExpression",
- start: {line: 1, column: 6},
callee: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "doThat",
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
}
],
- end: {line: 1, column: 17}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 17
+ }
+ }
},
handlers: [
{
type: "CatchClause",
- start: {line: 1, column: 18},
param: {
type: "Identifier",
- start: {line: 1, column: 25},
name: "e",
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
guard: null,
body: {
type: "BlockStatement",
- start: {line: 1, column: 28},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 30},
expression: {
type: "CallExpression",
- start: {line: 1, column: 30},
callee: {
type: "Identifier",
- start: {line: 1, column: 30},
name: "say",
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 34},
name: "e",
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 34
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
},
- end: {line: 1, column: 36}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 36
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
},
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
}
],
finalizer: {
type: "BlockStatement",
- start: {line: 1, column: 47},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 49},
expression: {
type: "CallExpression",
- start: {line: 1, column: 49},
callee: {
type: "Identifier",
- start: {line: 1, column: 49},
name: "cleanup",
- end: {line: 1, column: 56}
+ loc: {
+ start: {
+ line: 1,
+ column: 49
+ },
+ end: {
+ line: 1,
+ column: 56
+ }
+ }
},
arguments: [
{
type: "Identifier",
- start: {line: 1, column: 57},
name: "stuff",
- end: {line: 1, column: 62}
+ loc: {
+ start: {
+ line: 1,
+ column: 57
+ },
+ end: {
+ line: 1,
+ column: 62
+ }
+ }
}
],
- end: {line: 1, column: 63}
+ loc: {
+ start: {
+ line: 1,
+ column: 49
+ },
+ end: {
+ line: 1,
+ column: 63
+ }
+ }
},
- end: {line: 1, column: 63}
+ loc: {
+ start: {
+ line: 1,
+ column: 49
+ },
+ end: {
+ line: 1,
+ column: 63
+ }
+ }
}
],
- end: {line: 1, column: 65}
+ loc: {
+ start: {
+ line: 1,
+ column: 47
+ },
+ end: {
+ line: 1,
+ column: 65
+ }
+ }
},
- end: {line: 1, column: 65}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 65
+ }
+ }
}
],
- end: {line: 1, column: 65}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 65
+ }
+ }
});
test("debugger;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "DebuggerStatement",
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
},
{
type: "EmptyStatement",
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
}
],
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
});
test("function hello() { sayHi(); }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "hello",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 17},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 19},
expression: {
type: "CallExpression",
- start: {line: 1, column: 19},
callee: {
type: "Identifier",
- start: {line: 1, column: 19},
name: "sayHi",
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 26}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 26
+ }
+ }
},
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 19
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
});
test("function eval() { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "eval",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 16},
body: [],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
});
test("function arguments() { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "arguments",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 21},
body: [],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
}
],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
});
test("function test(t, t) { }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "test",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
params: [
{
type: "Identifier",
- start: {line: 1, column: 14},
name: "t",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 17},
name: "t",
- end: {line: 1, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 17
+ },
+ end: {
+ line: 1,
+ column: 18
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 20},
body: [],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
}
],
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
});
test("(function test(t, t) { })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: {
type: "Identifier",
- start: {line: 1, column: 10},
name: "test",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
params: [
{
type: "Identifier",
- start: {line: 1, column: 15},
name: "t",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 18},
name: "t",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 21},
body: [],
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 24}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 24
+ }
+ }
},
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
}
],
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
});
test("function eval() { function inner() { \"use strict\" } }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "eval",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 16},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 18},
id: {
type: "Identifier",
- start: {line: 1, column: 27},
name: "inner",
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 27
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 35},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 37},
expression: {
type: "Literal",
- start: {line: 1, column: 37},
value: "use strict",
- end: {line: 1, column: 49}
+ loc: {
+ start: {
+ line: 1,
+ column: 37
+ },
+ end: {
+ line: 1,
+ column: 49
+ }
+ }
},
- end: {line: 1, column: 49}
+ loc: {
+ start: {
+ line: 1,
+ column: 37
+ },
+ end: {
+ line: 1,
+ column: 49
+ }
+ }
}
],
- end: {line: 1, column: 51}
+ loc: {
+ start: {
+ line: 1,
+ column: 35
+ },
+ end: {
+ line: 1,
+ column: 51
+ }
+ }
},
- end: {line: 1, column: 51}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 51
+ }
+ }
}
],
- end: {line: 1, column: 53}
+ loc: {
+ start: {
+ line: 1,
+ column: 16
+ },
+ end: {
+ line: 1,
+ column: 53
+ }
+ }
},
- end: {line: 1, column: 53}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 53
+ }
+ }
}
],
- end: {line: 1, column: 53}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 53
+ }
+ }
});
test("function hello(a) { sayHi(); }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "hello",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
params: [
{
type: "Identifier",
- start: {line: 1, column: 15},
name: "a",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 18},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 20},
expression: {
type: "CallExpression",
- start: {line: 1, column: 20},
callee: {
type: "Identifier",
- start: {line: 1, column: 20},
name: "sayHi",
- end: {line: 1, column: 25}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 25
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
}
],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
});
test("function hello(a, b) { sayHi(); }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "FunctionDeclaration",
- start: {line: 1, column: 0},
id: {
type: "Identifier",
- start: {line: 1, column: 9},
name: "hello",
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
},
params: [
{
type: "Identifier",
- start: {line: 1, column: 15},
name: "a",
- end: {line: 1, column: 16}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 16
+ }
+ }
},
{
type: "Identifier",
- start: {line: 1, column: 18},
name: "b",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
body: {
type: "BlockStatement",
- start: {line: 1, column: 21},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 23},
expression: {
type: "CallExpression",
- start: {line: 1, column: 23},
callee: {
type: "Identifier",
- start: {line: 1, column: 23},
name: "sayHi",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 30}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 30
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 23
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
}
],
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
});
test("var hi = function() { sayHi() };", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "hi",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
init: {
type: "FunctionExpression",
- start: {line: 1, column: 9},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 20},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 22},
expression: {
type: "CallExpression",
- start: {line: 1, column: 22},
callee: {
type: "Identifier",
- start: {line: 1, column: 22},
name: "sayHi",
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
},
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 22
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
}
],
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 20
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
},
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 31}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 31
+ }
+ }
}
],
- end: {line: 1, column: 32}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ }
});
test("var hi = function eval() { };", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "hi",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
init: {
type: "FunctionExpression",
- start: {line: 1, column: 9},
id: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "eval",
- end: {line: 1, column: 22}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 22
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 25},
body: [],
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 25
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
},
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 28}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ }
}
],
- end: {line: 1, column: 29}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 29
+ }
+ }
});
test("var hi = function arguments() { };", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "hi",
- end: {line: 1, column: 6}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ }
},
init: {
type: "FunctionExpression",
- start: {line: 1, column: 9},
id: {
type: "Identifier",
- start: {line: 1, column: 18},
name: "arguments",
- end: {line: 1, column: 27}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 30},
body: [],
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 30
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
}
],
- end: {line: 1, column: 34}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 34
+ }
+ }
});
test("var hello = function hi() { sayHi() };", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "hello",
- end: {line: 1, column: 9}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 9
+ }
+ }
},
init: {
type: "FunctionExpression",
- start: {line: 1, column: 12},
id: {
type: "Identifier",
- start: {line: 1, column: 21},
name: "hi",
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 21
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 26},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 28},
expression: {
type: "CallExpression",
- start: {line: 1, column: 28},
callee: {
type: "Identifier",
- start: {line: 1, column: 28},
name: "sayHi",
- end: {line: 1, column: 33}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ }
},
arguments: [],
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
},
- end: {line: 1, column: 35}
+ loc: {
+ start: {
+ line: 1,
+ column: 28
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ }
}
],
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 26
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
},
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 12
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
},
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 37}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ }
}
],
- end: {line: 1, column: 38}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ }
});
test("(function(){})", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [],
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
}
],
- end: {line: 1, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 14
+ }
+ }
});
test("{ x\n++y }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 2},
expression: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "x",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 2, column: 0},
operator: "++",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 2, column: 2},
name: "y",
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 2
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
},
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
},
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
});
test("{ x\n--y }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 2},
expression: {
type: "Identifier",
- start: {line: 1, column: 2},
name: "x",
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
- end: {line: 1, column: 3}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 3
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "UpdateExpression",
- start: {line: 2, column: 0},
operator: "--",
prefix: true,
argument: {
type: "Identifier",
- start: {line: 2, column: 2},
name: "y",
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 2
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
},
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
},
- end: {line: 2, column: 3}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 3
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
});
test("var x /* comment */;", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 0},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 4},
id: {
type: "Identifier",
- start: {line: 1, column: 4},
name: "x",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
},
init: null,
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 4
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 5
+ }
+ }
}
],
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
});
test("{ var x = 14, y = 3\nz; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "VariableDeclaration",
- start: {line: 1, column: 2},
declarations: [
{
type: "VariableDeclarator",
- start: {line: 1, column: 6},
id: {
type: "Identifier",
- start: {line: 1, column: 6},
name: "x",
- end: {line: 1, column: 7}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 7
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 10},
value: 14,
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 10
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
- end: {line: 1, column: 12}
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ }
},
{
type: "VariableDeclarator",
- start: {line: 1, column: 14},
id: {
type: "Identifier",
- start: {line: 1, column: 14},
name: "y",
- end: {line: 1, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 15
+ }
+ }
},
init: {
type: "Literal",
- start: {line: 1, column: 18},
value: 3,
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 18
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 14
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
}
],
kind: "var",
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "z",
- end: {line: 2, column: 1}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 1
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
}
],
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
});
test("while (true) { continue\nthere; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "there",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
},
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("while (true) { continue // Comment\nthere; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "there",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
},
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("while (true) { continue /* Multiline\nComment */there; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "ContinueStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 23}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 23
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 10},
expression: {
type: "Identifier",
- start: {line: 2, column: 10},
name: "there",
- end: {line: 2, column: 15}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 15
+ }
+ }
},
- end: {line: 2, column: 16}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 16
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
},
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
});
test("while (true) { break\nthere; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "there",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
},
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("while (true) { break // Comment\nthere; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "there",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
},
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("while (true) { break /* Multiline\nComment */there; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "WhileStatement",
- start: {line: 1, column: 0},
test: {
type: "Literal",
- start: {line: 1, column: 7},
value: true,
- end: {line: 1, column: 11}
+ loc: {
+ start: {
+ line: 1,
+ column: 7
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
},
body: {
type: "BlockStatement",
- start: {line: 1, column: 13},
body: [
{
type: "BreakStatement",
- start: {line: 1, column: 15},
label: null,
- end: {line: 1, column: 20}
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 20
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 10},
expression: {
type: "Identifier",
- start: {line: 2, column: 10},
name: "there",
- end: {line: 2, column: 15}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 15
+ }
+ }
},
- end: {line: 2, column: 16}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 16
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
},
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
});
test("(function(){ return\nx; })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: null,
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "x",
- end: {line: 2, column: 1}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 1
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
},
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
},
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
});
test("(function(){ return // Comment\nx; })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: null,
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "x",
- end: {line: 2, column: 1}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 1
+ }
+ }
},
- end: {line: 2, column: 2}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 2
+ }
+ }
}
],
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
},
- end: {line: 2, column: 4}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 2,
+ column: 4
+ }
+ }
},
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
}
],
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
});
test("(function(){ return/* Multiline\nComment */x; })", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "ExpressionStatement",
- start: {line: 1, column: 0},
expression: {
type: "FunctionExpression",
- start: {line: 1, column: 1},
id: null,
params: [],
body: {
type: "BlockStatement",
- start: {line: 1, column: 11},
body: [
{
type: "ReturnStatement",
- start: {line: 1, column: 13},
argument: null,
- end: {line: 1, column: 19}
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 19
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 10},
expression: {
type: "Identifier",
- start: {line: 2, column: 10},
name: "x",
- end: {line: 2, column: 11}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 11
+ }
+ }
},
- end: {line: 2, column: 12}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 12
+ }
+ }
}
],
- end: {line: 2, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 2,
+ column: 14
+ }
+ }
},
- end: {line: 2, column: 14}
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 2,
+ column: 14
+ }
+ }
},
- end: {line: 2, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 15
+ }
+ }
}
],
- end: {line: 2, column: 15}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 15
+ }
+ }
});
test("{ throw error\nerror; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 2},
argument: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "error",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "error",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("{ throw error// Comment\nerror; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 2},
argument: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "error",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 0},
expression: {
type: "Identifier",
- start: {line: 2, column: 0},
name: "error",
- end: {line: 2, column: 5}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 5
+ }
+ }
},
- end: {line: 2, column: 6}
+ loc: {
+ start: {
+ line: 2,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 6
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
}
],
- end: {line: 2, column: 8}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 8
+ }
+ }
});
test("{ throw error/* Multiline\nComment */error; }", {
type: "Program",
- start: {line: 1, column: 0},
body: [
{
type: "BlockStatement",
- start: {line: 1, column: 0},
body: [
{
type: "ThrowStatement",
- start: {line: 1, column: 2},
argument: {
type: "Identifier",
- start: {line: 1, column: 8},
name: "error",
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 8
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
- end: {line: 1, column: 13}
+ loc: {
+ start: {
+ line: 1,
+ column: 2
+ },
+ end: {
+ line: 1,
+ column: 13
+ }
+ }
},
{
type: "ExpressionStatement",
- start: {line: 2, column: 10},
expression: {
type: "Identifier",
- start: {line: 2, column: 10},
name: "error",
- end: {line: 2, column: 15}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 15
+ }
+ }
},
- end: {line: 2, column: 16}
+ loc: {
+ start: {
+ line: 2,
+ column: 10
+ },
+ end: {
+ line: 2,
+ column: 16
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
}
],
- end: {line: 2, column: 18}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 2,
+ column: 18
+ }
+ }
});
test("", {
type: "Program",
- start: {line: 1, column: 0},
body: [],
- end: {line: 1, column: 0}
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 0
+ }
+ }
});
// Failure tests
@@ -11392,7 +25754,7 @@ testFail("3x0",
"Identifier directly after number (1:1)");
testFail("0x",
- "Expected hexadecimal number (undefined:undefined)");
+ "Expected hexadecimal number (1:2)");
testFail("09",
"Invalid number (1:0)");