1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00
serenity/Libraries/LibJS/Tests
mattco98 adb4accab3 LibJS: Add template literals
Adds fully functioning template literals. Because template literals
contain expressions, most of the work has to be done in the Lexer rather
than the Parser. And because of the complexity of template literals
(expressions, nesting, escapes, etc), the Lexer needs to have some
template-related state.

When entering a new template literal, a TemplateLiteralStart token is
emitted. When inside a literal, all text will be parsed up until a '${'
or '`' (or EOF, but that's a syntax error) is seen, and then a
TemplateLiteralExprStart token is emitted. At this point, the Lexer
proceeds as normal, however it keeps track of the number of opening
and closing curly braces it has seen in order to determine the close
of the expression. Once it finds a matching curly brace for the '${',
a TemplateLiteralExprEnd token is emitted and the state is updated
accordingly.

When the Lexer is inside of a template literal, but not an expression,
and sees a '`', this must be the closing grave: a TemplateLiteralEnd
token is emitted.

The state required to correctly parse template strings consists of a
vector (for nesting) of two pieces of information: whether or not we
are in a template expression (as opposed to a template string); and
the count of the number of unmatched open curly braces we have seen
(only applicable if the Lexer is currently in a template expression).

TODO: Add support for template literal newlines in the JS REPL (this will
cause a syntax error currently):

    > `foo
    > bar`
    'foo
    bar'
2020-05-04 16:46:31 +02:00
..
add-values-to-primitive.js LibJS: Adding two values should convert them to primitives first 2020-04-15 09:48:25 +02:00
array-basic.js LibJS: Support empty values in array expression 2020-04-15 21:23:06 +02:00
array-length-setter.js LibJS: Implement Array length setter 2020-04-23 09:47:23 +02:00
array-shrink-during-find-crash.js LibJS: Call Array.prototype.findIndex() callback for empty elements 2020-04-28 20:15:38 +02:00
array-spread.js LibJS: Support spreading of strings and string objects 2020-04-28 15:35:24 +02:00
Array.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Array.prototype.concat.js LibJS: Add Array.prototype.concat 2020-04-17 16:14:28 +02:00
Array.prototype.filter.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
Array.prototype.find.js LibJS: Call Array.prototype.find() callback for empty elements 2020-04-28 20:15:38 +02:00
Array.prototype.findIndex.js LibJS: Call Array.prototype.findIndex() callback for empty elements 2020-04-28 20:15:38 +02:00
Array.prototype.forEach.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
Array.prototype.includes.js LibJS: Add Array.prototype.includes 2020-04-23 19:30:16 +02:00
Array.prototype.indexOf.js LibJS: Fix Array.prototype.indexOf fromIndex negative 2020-04-23 11:06:10 +02:00
Array.prototype.join.js LibJS: Skip undefined and null in join_array_with_separator() 2020-04-29 01:30:59 +02:00
Array.prototype.lastIndexOf.js LibJS: Add Array.prototype.lastIndexOf 2020-04-22 13:08:00 +02:00
Array.prototype.map.js LibJS: Let Array.prototype.map() resize new array before loop 2020-04-28 20:15:38 +02:00
Array.prototype.pop.js LibJS: Return undefined in Array.prototype.{pop,shift} for empty values 2020-04-29 09:38:25 +02:00
Array.prototype.push.js LibJS: Support multiple arguments in Array.prototype.push() 2020-04-14 13:40:04 +02:00
Array.prototype.reverse.js LibJS: Add Array.prototype.reverse 2020-04-20 17:26:46 +02:00
Array.prototype.shift.js LibJS: Return undefined in Array.prototype.{pop,shift} for empty values 2020-04-29 09:38:25 +02:00
Array.prototype.slice.js LibJS: Add Array.prototype.slice 2020-04-19 02:09:06 +02:00
Array.prototype.some.js LibJS: Add Array.prototype.some 2020-04-28 13:11:10 +02:00
Array.prototype.toString.js LibJS: Skip undefined and null in join_array_with_separator() 2020-04-29 01:30:59 +02:00
Array.prototype.unshift.js LibJS: Add Array.prototype.unshift() 2020-04-14 13:40:04 +02:00
arrow-functions.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
automatic-semicolon-insertion.js LibJS: Fix parsing of IfStatement, fixes #1829 2020-04-18 14:04:24 +02:00
binary-bitwise-left-shift.js LibJS: Implement bitwise left shift operator (<<) 2020-04-23 19:38:13 +02:00
binary-bitwise-or.js LibJS: Implement bitwise left shift operator (<<) 2020-04-23 19:38:13 +02:00
binary-bitwise-right-shift.js LibJS: Implement bitwise right shift operator (>>) 2020-04-23 19:38:13 +02:00
binary-bitwise-unsigned-right-shift.js LibJS: Implement bitwise unsigned right shift operator (>>>) 2020-04-23 19:38:13 +02:00
Boolean.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Boolean.prototype.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Boolean.prototype.toString.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
Boolean.prototype.valueOf.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
comments-basic.js LibJS: Add missing load("test-common.js") to comments-basic.js 2020-04-14 17:26:57 +02:00
constructor-basic.js LibJS: Implement basic support for the "new" keyword 2020-03-28 16:33:52 +01:00
continue-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Date.now.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getDate.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getDay.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getFullYear.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getHours.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getMilliseconds.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getMinutes.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getMonth.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getSeconds.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Date.prototype.getTime.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
debugger-statement.js LibJS: Implement (no-op) debugger statement 2020-05-01 22:07:13 +02:00
delete-basic.js LibJS: Implement basic support for the "delete" operator 2020-04-26 15:51:07 +02:00
delete-global-variable.js LibJS: Allow "delete someGlobalVariable" 2020-04-28 15:07:08 +02:00
delete-globalThis-property-crash.js LibJS: Grow storage when adding a property to uniquely-shaped Object 2020-04-26 19:05:08 +02:00
do-while-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
empty-statements.js LibJS: Support empty statements 2020-05-03 12:57:48 +02:00
Error.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Error.prototype.name.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Error.prototype.toString.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
exception-ReferenceError.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
exponentiation-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
for-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
for-head-errors.js LibJS: Handle exception in for loop test execution 2020-04-28 23:11:18 +02:00
for-no-curlies.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
function-default-parameters.js LibJS: Add function default arguments 2020-05-03 00:44:57 +02:00
function-length.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
function-missing-arg.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
function-name.js LibJS: Set name of anonymous functions during assignment 2020-05-03 11:41:56 +02:00
function-this-in-arguments.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
function-TypeError.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
Function.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Function.prototype.apply.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Function.prototype.bind.js LibJS: Implement Function.prototype.bind() 2020-04-21 12:23:07 +02:00
Function.prototype.call.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Function.prototype.toString.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
in-operator-basic.js LibJS: Implement 'in' operator 2020-04-23 19:38:13 +02:00
indexed-access-string-object.js LibJS: Implement indexed access for StringObject 2020-05-01 16:54:01 +02:00
Infinity-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
instanceof-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
invalid-lhs-in-assignment.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
isFinite.js LibJS: Implement Number.isFinite() 2020-04-26 20:36:59 +02:00
isNaN.js LibJS: Let isNaN() with no argument return true, add tests 2020-04-23 11:03:42 +02:00
let-scoping.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
logical-expressions-basic.js LibJS: Implement nullish coalescing operator (??) 2020-04-18 12:34:13 +02:00
logical-expressions-short-circuit.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math-constants.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.abs.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.ceil.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.cos.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.max.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.min.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.pow.js LibJS: Add Math.pow() 2020-04-23 19:38:13 +02:00
Math.sin.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.sqrt.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.tan.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Math.trunc.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
modulo-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
NaN-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Number-constants.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Number.isFinite.js LibJS: Implement Number.isFinite() 2020-04-26 20:36:59 +02:00
Number.isInteger.js LibJS: Make Number.isInteger() test pass on Serenity 2020-04-28 14:49:43 +02:00
Number.isNaN.js LibJS: Implement Number.isNaN() 2020-04-26 20:36:59 +02:00
Number.isSafeInteger.js LibJS: Implement Number.isFinite() 2020-04-26 20:36:59 +02:00
Number.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Number.prototype.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
numeric-literals-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
object-basic.js LibJS: Implement computed properties in object expressions 2020-04-23 23:56:04 +02:00
object-method-shorthand.js LibJS: Add object literal method shorthand 2020-05-01 12:28:40 +02:00
object-spread.js LibJS: Add spreading in object literals 2020-04-28 20:37:21 +02:00
Object.defineProperty.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
Object.entries.js LibJS: Add Object.{keys,values,entries}() 2020-04-30 09:53:16 +02:00
Object.getOwnPropertyNames.js LibJS: Implement correct object property ordering 2020-04-29 18:47:03 +02:00
Object.getPrototypeOf.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Object.is.js LibJS: Implement Object.is() 2020-04-26 13:53:05 +02:00
Object.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
Object.keys.js LibJS: Add Object.{keys,values,entries}() 2020-04-30 09:53:16 +02:00
Object.prototype.constructor.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Object.prototype.hasOwnProperty.js LibJS: Handle Object.prototype.hasOwnProperty() with no arg correctly 2020-04-28 20:03:50 +02:00
Object.prototype.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Object.prototype.toString.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Object.values.js LibJS: Add Object.{keys,values,entries}() 2020-04-30 09:53:16 +02:00
parser-unary-associativity.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
Reflect.apply.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.construct.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.defineProperty.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.deleteProperty.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.get.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.getOwnPropertyDescriptor.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.getPrototypeOf.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.has.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.ownKeys.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.set.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
Reflect.setPrototypeOf.js LibJS: Implement most of the Reflect object 2020-05-01 16:54:01 +02:00
run-tests LibJS: Let run-tests return 1 when not all tests pass 2020-04-20 22:44:13 +02:00
string-spread.js LibJS: Support spreading of strings and string objects 2020-04-28 15:35:24 +02:00
String.js LibJS: Add "name" property to functions 2020-05-02 20:41:31 +02:00
String.prototype-generic-functions.js LibJS: Make String.prototype.slice() generic 2020-04-29 19:14:36 +02:00
String.prototype.charAt.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.concat.js LibJS: Add String.prototype.concat 2020-04-16 16:36:51 +02:00
String.prototype.includes.js LibJS: Add String.prototype.includes 2020-04-25 16:54:25 +02:00
String.prototype.indexOf.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.lastIndexOf.js LibJS: Add String.prototype.lastIndexOf 2020-05-01 16:50:37 +02:00
String.prototype.padEnd.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.padStart.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.repeat.js LibJS: Add tests for String.prototype.repeat() 2020-04-20 11:41:25 +02:00
String.prototype.slice.js LibJS: Add String.prototype.slice 2020-04-29 18:35:18 +02:00
String.prototype.startsWith.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.substring.js LibJS: Add String.prototype.substring 2020-04-16 18:47:24 +02:00
String.prototype.toLowerCase.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.toString.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.toUpperCase.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
String.prototype.trim.js LibJS: Add String.prototype.{trim, trimStart, trimEnd} (#1792) 2020-04-15 08:47:40 +02:00
switch-basic-2.js LibJS: Use assertNotReached() in tests 2020-04-13 16:28:50 +02:00
switch-basic-3.js LibJS: Fix test files indentation (4 spaces) 2020-04-13 16:28:50 +02:00
switch-basic.js LibJS: Fix test files indentation (4 spaces) 2020-04-13 16:28:50 +02:00
switch-break.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
template-literals.js LibJS: Add template literals 2020-05-04 16:46:31 +02:00
ternary-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
test-common.js LibJS: Remove default parameter from assertThrowsError() for now 2020-04-20 20:33:21 +02:00
throw-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
to-number-basic.js LibJS: Don't handle arrays separately in Value::to_number() 2020-04-29 01:30:59 +02:00
typeof-basic.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
update-expression-on-member-expression.js LibJS: Support o.f++ :^) 2020-04-28 15:07:08 +02:00
update-expressions-basic.js LibJS: Improve UpdateExpression::execute() 2020-04-22 13:09:59 +02:00
var-multiple-declarator.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
var-scoping.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
variable-declaration.js LibJS: Add assertThrowsError() test function 2020-04-20 11:38:01 +02:00
variable-undefined.js js/LibJS: Move test functions to pure javascript. 2020-04-14 12:55:31 +02:00
void-basic.js LibJS: Implement void operator 2020-04-15 19:12:51 +02:00
while-basic.js LibJS: Parse while statements 2020-04-22 11:48:14 +02:00