Browse Source

2019-09-01

- added globalThis
- documented JS_EVAL_FLAG_COMPILE_ONLY
- added import.meta.url and import.meta.main
- added 'debugger' statement
- misc bug fixes
pull/11/head 20190901
Horunabu Hofutenho 1 year ago
parent
commit
1355490ec1
No known key found for this signature in database GPG Key ID: 7EB80FA93BC3054C
23 changed files with 391 additions and 187 deletions
  1. +8
    -0
      Changelog
  2. +3
    -3
      TODO
  3. +1
    -1
      VERSION
  4. +0
    -1
      cutils.c
  5. +9
    -12
      doc/jsbignum.html
  6. BIN
      doc/jsbignum.pdf
  7. +0
    -2
      doc/jsbignum.texi
  8. +11
    -16
      doc/quickjs.html
  9. BIN
      doc/quickjs.pdf
  10. +2
    -5
      doc/quickjs.texi
  11. +14
    -2
      qjs.c
  12. +3
    -2
      qjsc.c
  13. +1
    -0
      quickjs-atom.h
  14. +115
    -15
      quickjs-libc.c
  15. +2
    -0
      quickjs-libc.h
  16. +156
    -96
      quickjs.c
  17. +11
    -5
      quickjs.h
  18. +2
    -2
      release.sh
  19. +1
    -4
      repl.js
  20. +2
    -6
      run-test262.c
  21. +0
    -7
      test262.conf
  22. +0
    -7
      test262bn.conf
  23. +50
    -1
      tests/test262.patch

+ 8
- 0
Changelog View File

@ -1,3 +1,11 @@
2019-09-01:
- added globalThis
- documented JS_EVAL_FLAG_COMPILE_ONLY
- added import.meta.url and import.meta.main
- added 'debugger' statement
- misc bug fixes
2019-08-18:
- added os.realpath, os.getcwd, os.mkdir, os.stat, os.lstat,

+ 3
- 3
TODO View File

@ -75,6 +75,6 @@ REPL:
Test262o: 0/11262 errors, 463 excluded
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
Test262: 2/67090 errors, 842 excluded, 1386 skipped
Test262bn: 2/69191 errors, 775 excluded, 399 skipped
test262 commit: 59a1a016b7cf5cf43f66b274c7d1db4ec6066935
Test262: 2/67303 errors, 839 excluded, 1390 skipped
Test262bn: 2/69404 errors, 772 excluded, 403 skipped
test262 commit: b63cdfd4f4a00f5fdb732778244d3456725f46c9

+ 1
- 1
VERSION View File

@ -1 +1 @@
2019-08-18
2019-09-01

+ 0
- 1
cutils.c View File

@ -572,7 +572,6 @@ void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
*/
span = plt - ptr;
span2 = pi - plt;
plt = pi - span;
lt = i - lt;
if (span > span2)
span = span2;

+ 9
- 12
doc/jsbignum.html View File

@ -1,7 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Javascript Bignum Extensions</title>
<meta name="description" content="Javascript Bignum Extensions">
@ -9,21 +10,20 @@
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
@ -32,10 +32,9 @@ pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
@ -44,7 +43,7 @@ ul.no-bullet {list-style: none}
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<body lang="en">
<h1 class="settitle" align="center">Javascript Bignum Extensions</h1>
<a name="SEC_Contents"></a>
@ -357,8 +356,6 @@ BigInt is not observable (i.e. they are both integers).
</li><li> Operators with integer operands never return the minus zero floating point value as result. Hence <code>Object.is(0, -0) === true</code>. Use <code>-0.0</code> to create a minus zero floating point value.
</li><li> Division or modulo with a zero integer dividend raises an exception i.e. <code>1/0</code> throws a <code>RangeError</code> exception. However, division by the floating point zero returns Infinity or NaN as in standard mode: <code>1/0.0 === Infinity</code>. The same holds for zero elevated to a negative integer power i.e. <code>0**-1</code> throws a <code>RangeError</code> exception.
</li><li> The <code>ToPrimitive</code> abstract operation is called with the <code>&quot;integer&quot;</code> preferred type when an integer is required (e.g. for bitwise binary or shift operations).
</li><li> The prototype of integers is no longer <code>Number.prototype</code>. Instead<br> <code>Object.getPrototypeOf(1) === BigInt.prototype</code>. The prototype of floats remains Number.prototype.

BIN
doc/jsbignum.pdf View File


+ 0
- 2
doc/jsbignum.texi View File

@ -238,8 +238,6 @@ The following changes are visible:
@item Operators with integer operands never return the minus zero floating point value as result. Hence @code{Object.is(0, -0) === true}. Use @code{-0.0} to create a minus zero floating point value.
@item Division or modulo with a zero integer dividend raises an exception i.e. @code{1/0} throws a @code{RangeError} exception. However, division by the floating point zero returns Infinity or NaN as in standard mode: @code{1/0.0 === Infinity}. The same holds for zero elevated to a negative integer power i.e. @code{0**-1} throws a @code{RangeError} exception.
@item The @code{ToPrimitive} abstract operation is called with the @code{"integer"} preferred type when an integer is required (e.g. for bitwise binary or shift operations).
@item The prototype of integers is no longer @code{Number.prototype}. Instead@* @code{Object.getPrototypeOf(1) === BigInt.prototype}. The prototype of floats remains Number.prototype.

+ 11
- 16
doc/quickjs.html View File

@ -1,7 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>QuickJS Javascript Engine</title>
<meta name="description" content="QuickJS Javascript Engine">
@ -9,21 +10,20 @@
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
@ -32,10 +32,9 @@ pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
@ -44,7 +43,7 @@ ul.no-bullet {list-style: none}
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<body lang="en">
<h1 class="settitle" align="center">QuickJS Javascript Engine</h1>
<a name="SEC_Contents"></a>
@ -386,8 +385,8 @@ options of the test262 runner.
<code>test262-harness</code><a name="DOCF5" href="#FOOT5"><sup>5</sup></a>
thru <code>eshost</code>. Unless you want to compare QuickJS with other
engines under the same conditions, we do not recommend to run the
tests this way as it is much slower (typically more than one hour
instead of about 100 seconds).
tests this way as it is much slower (typically half an hour instead of
about 100 seconds).
</p>
<a name="Specifications"></a>
<h2 class="chapter">3 Specifications</h2>
@ -577,10 +576,6 @@ and stdio.h and a few other utilities.
<dd><p>Constants for seek().
</p>
</dd>
<dt><code>global</code></dt>
<dd><p>Reference to the global object.
</p>
</dd>
<dt><code>gc()</code></dt>
<dd><p>Manually invoke the cycle removal algorithm. The cycle removal
algorithm is automatically started when needed, so this function is

BIN
doc/quickjs.pdf View File


+ 2
- 5
doc/quickjs.texi View File

@ -256,8 +256,8 @@ options of the test262 runner.
@code{test262-harness}@footnote{@url{https://github.com/bterlson/test262-harness}}
thru @code{eshost}. Unless you want to compare QuickJS with other
engines under the same conditions, we do not recommend to run the
tests this way as it is much slower (typically more than one hour
instead of about 100 seconds).
tests this way as it is much slower (typically half an hour instead of
about 100 seconds).
@chapter Specifications
@ -424,9 +424,6 @@ Wrappers to the libc file @code{stdin}, @code{stdout}, @code{stderr}.
@item SEEK_END
Constants for seek().
@item global
Reference to the global object.
@item gc()
Manually invoke the cycle removal algorithm. The cycle removal
algorithm is automatically started when needed, so this function is

+ 14
- 2
qjs.c View File

@ -54,7 +54,18 @@ static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
JSValue val;
int ret;
val = JS_Eval(ctx, buf, buf_len, filename, eval_flags);
if ((eval_flags & JS_EVAL_TYPE_MASK) == JS_EVAL_TYPE_MODULE) {
/* for the modules, we compile then run to be able to set
import.meta */
val = JS_Eval(ctx, buf, buf_len, filename,
eval_flags | JS_EVAL_FLAG_COMPILE_ONLY);
if (!JS_IsException(val)) {
js_module_set_import_meta(ctx, val, TRUE, TRUE);
val = JS_EvalFunction(ctx, val);
}
} else {
val = JS_Eval(ctx, buf, buf_len, filename, eval_flags);
}
if (JS_IsException(val)) {
js_std_dump_error(ctx);
ret = -1;
@ -78,7 +89,8 @@ static int eval_file(JSContext *ctx, const char *filename, int module)
}
if (module < 0) {
module = JS_DetectModule((const char *)buf, buf_len);
module = (has_suffix(filename, ".mjs") ||
JS_DetectModule((const char *)buf, buf_len));
}
if (module)
eval_flags = JS_EVAL_TYPE_MODULE;

+ 3
- 2
qjsc.c View File

@ -281,7 +281,8 @@ static void compile_file(JSContext *ctx, FILE *fo,
}
eval_flags = JS_EVAL_FLAG_COMPILE_ONLY;
if (module < 0) {
module = JS_DetectModule((const char *)buf, buf_len);
module = (has_suffix(filename, ".mjs") ||
JS_DetectModule((const char *)buf, buf_len));
}
if (module)
eval_flags |= JS_EVAL_TYPE_MODULE;
@ -648,7 +649,7 @@ int main(int argc, char **argv)
namelist_entry_t *e = &cname_list.array[i];
fprintf(fo, " js_std_eval_binary(ctx, %s, %s_size, %s);\n",
e->name, e->name,
e->flags ? "JS_EVAL_BINARY_LOAD_ONLY" : "0");
e->flags ? "1" : "0");
}
fputs(main_c_template2, fo);
}

+ 1
- 0
quickjs-atom.h View File

@ -166,6 +166,7 @@ DEF(exec, "exec")
DEF(groups, "groups")
DEF(status, "status")
DEF(reason, "reason")
DEF(globalThis, "globalThis")
#ifdef CONFIG_BIGNUM
DEF(bigint, "bigint")
DEF(bigfloat, "bigfloat")

+ 115
- 15
quickjs-libc.c View File

@ -303,18 +303,40 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename)
FILE *f;
uint8_t *buf;
size_t buf_len;
long lret;
f = fopen(filename, "rb");
if (!f)
return NULL;
fseek(f, 0, SEEK_END);
buf_len = ftell(f);
fseek(f, 0, SEEK_SET);
if (fseek(f, 0, SEEK_END) < 0)
goto fail;
lret = ftell(f);
if (lret < 0)
goto fail;
/* XXX: on Linux, ftell() return LONG_MAX for directories */
if (lret == LONG_MAX) {
errno = EISDIR;
goto fail;
}
buf_len = lret;
if (fseek(f, 0, SEEK_SET) < 0)
goto fail;
if (ctx)
buf = js_malloc(ctx, buf_len + 1);
else
buf = malloc(buf_len + 1);
fread(buf, 1, buf_len, f);
if (!buf)
goto fail;
if (fread(buf, 1, buf_len, f) != buf_len) {
errno = EIO;
if (ctx)
js_free(ctx, buf);
else
free(buf);
fail:
fclose(f);
return NULL;
}
buf[buf_len] = '\0';
fclose(f);
*pbuf_len = buf_len;
@ -408,6 +430,56 @@ static JSModuleDef *js_module_loader_so(JSContext *ctx,
}
#endif /* !_WIN32 */
int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
JS_BOOL use_realpath, JS_BOOL is_main)
{
JSModuleDef *m;
char buf[PATH_MAX + 16], *res;
JSValue meta_obj;
JSAtom module_name_atom;
const char *module_name;
assert(JS_VALUE_GET_TAG(func_val) == JS_TAG_MODULE);
m = JS_VALUE_GET_PTR(func_val);
module_name_atom = JS_GetModuleName(ctx, m);
module_name = JS_AtomToCString(ctx, module_name_atom);
JS_FreeAtom(ctx, module_name_atom);
if (!module_name)
return -1;
if (!strchr(module_name, ':')) {
strcpy(buf, "file://");
/* realpath() cannot be used with modules compiled with qjsc
because the corresponding module source code is not
necessarily present */
if (use_realpath) {
res = realpath(module_name, buf + strlen(buf));
if (!res) {
JS_ThrowTypeError(ctx, "realpath failure");
JS_FreeCString(ctx, module_name);
return -1;
}
} else {
pstrcat(buf, sizeof(buf), module_name);
}
} else {
pstrcpy(buf, sizeof(buf), module_name);
}
JS_FreeCString(ctx, module_name);
meta_obj = JS_GetImportMeta(ctx, m);
if (JS_IsException(meta_obj))
return -1;
JS_DefinePropertyValueStr(ctx, meta_obj, "url",
JS_NewString(ctx, buf),
JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, meta_obj, "main",
JS_NewBool(ctx, is_main),
JS_PROP_C_W_E);
JS_FreeValue(ctx, meta_obj);
return 0;
}
JSModuleDef *js_module_loader(JSContext *ctx,
const char *module_name, void *opaque)
{
@ -433,6 +505,8 @@ JSModuleDef *js_module_loader(JSContext *ctx,
js_free(ctx, buf);
if (JS_IsException(func_val))
return NULL;
/* XXX: could propagate the exception */
js_module_set_import_meta(ctx, func_val, TRUE, FALSE);
/* the module is already referenced, so we must free it */
m = JS_VALUE_GET_PTR(func_val);
JS_FreeValue(ctx, func_val);
@ -1202,8 +1276,6 @@ static int js_std_init(JSContext *ctx, JSModuleDef *m)
countof(js_std_error_funcs));
JS_SetModuleExport(ctx, m, "Error", obj);
/* global object */
JS_SetModuleExport(ctx, m, "global", JS_GetGlobalObject(ctx));
return 0;
}
@ -1217,7 +1289,6 @@ JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name)
JS_AddModuleExport(ctx, m, "in");
JS_AddModuleExport(ctx, m, "out");
JS_AddModuleExport(ctx, m, "err");
JS_AddModuleExport(ctx, m, "global");
JS_AddModuleExport(ctx, m, "Error");
return m;
}
@ -1999,6 +2070,17 @@ static JSValue js_os_stat(JSContext *ctx, JSValueConst this_val,
JS_DefinePropertyValueStr(ctx, obj, "blocks",
JS_NewInt64(ctx, st.st_blocks),
JS_PROP_C_W_E);
#if defined(__APPLE__)
JS_DefinePropertyValueStr(ctx, obj, "atime",
JS_NewInt64(ctx, timespec_to_ms(&st.st_atimespec)),
JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "mtime",
JS_NewInt64(ctx, timespec_to_ms(&st.st_mtimespec)),
JS_PROP_C_W_E);
JS_DefinePropertyValueStr(ctx, obj, "ctime",
JS_NewInt64(ctx, timespec_to_ms(&st.st_ctimespec)),
JS_PROP_C_W_E);
#else
JS_DefinePropertyValueStr(ctx, obj, "atime",
JS_NewInt64(ctx, timespec_to_ms(&st.st_atim)),
JS_PROP_C_W_E);
@ -2008,6 +2090,7 @@ static JSValue js_os_stat(JSContext *ctx, JSValueConst this_val,
JS_DefinePropertyValueStr(ctx, obj, "ctime",
JS_NewInt64(ctx, timespec_to_ms(&st.st_ctim)),
JS_PROP_C_W_E);
#endif
}
return make_obj_error(ctx, obj, err);
}
@ -2341,13 +2424,30 @@ void js_std_loop(JSContext *ctx)
}
void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
int flags)
int load_only)
{
JSValue val;
val = JS_EvalBinary(ctx, buf, buf_len, flags);
if (JS_IsException(val)) {
js_std_dump_error(ctx);
exit(1);
JSValue obj, val;
obj = JS_ReadObject(ctx, buf, buf_len, JS_READ_OBJ_BYTECODE);
if (JS_IsException(obj))
goto exception;
if (load_only) {
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
js_module_set_import_meta(ctx, obj, FALSE, FALSE);
}
} else {
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
if (JS_ResolveModule(ctx, obj) < 0) {
JS_FreeValue(ctx, obj);
goto exception;
}
js_module_set_import_meta(ctx, obj, FALSE, TRUE);
}
val = JS_EvalFunction(ctx, obj);
if (JS_IsException(val)) {
exception:
js_std_dump_error(ctx);
exit(1);
}
JS_FreeValue(ctx, val);
}
JS_FreeValue(ctx, val);
}

+ 2
- 0
quickjs-libc.h View File

@ -36,6 +36,8 @@ void js_std_loop(JSContext *ctx);
void js_std_free_handlers(JSRuntime *rt);
void js_std_dump_error(JSContext *ctx);
uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
JS_BOOL use_realpath, JS_BOOL is_main);
JSModuleDef *js_module_loader(JSContext *ctx,
const char *module_name, void *opaque);
void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,

+ 156
- 96
quickjs.c View File

@ -12240,11 +12240,6 @@ static no_inline __exception int js_add_slow(JSContext *ctx, JSValue *sp)
bf_delete(b);
JS_FreeValue(ctx, op1);
JS_FreeValue(ctx, op2);
if (unlikely(ret)) {
bf_delete(r);
throw_bf_exception(ctx, ret);
goto exception;
}
sp[-2] = JS_NewBigFloat(ctx, r);
}
return 0;
@ -20902,6 +20897,14 @@ static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL no_line_
}
break;
}
/* last_tok is only used to recognize regexps */
if (s->token.val == TOK_IDENT &&
(token_is_pseudo_keyword(s, JS_ATOM_of) ||
token_is_pseudo_keyword(s, JS_ATOM_yield))) {
last_tok = TOK_OF;
} else {
last_tok = s->token.val;
}
if (next_token(s)) {
/* XXX: should clear the exception generated by next_token() */
break;
@ -20914,14 +20917,6 @@ static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL no_line_
tok = '\n';
break;
}
/* last_ok is only used to recognize regexps */
if (s->token.val == TOK_IDENT &&
(token_is_pseudo_keyword(s, JS_ATOM_of) ||
token_is_pseudo_keyword(s, JS_ATOM_yield))) {
last_tok = TOK_OF;
} else {
last_tok = s->token.val;
}
}
done:
if (pbits) {
@ -25095,6 +25090,13 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
break;
case TOK_DEBUGGER:
/* currently no debugger, so just skip the keyword */
if (next_token(s))
goto fail;
if (js_parse_expect_semi(s))
goto fail;
break;
case TOK_ENUM:
case TOK_EXPORT:
case TOK_EXTENDS:
@ -26185,11 +26187,29 @@ static JSAtom js_get_script_or_module_name(JSContext *ctx)
return b->debug.filename;
}
JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
{
return JS_DupAtom(ctx, m->module_name);
}
JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m)
{
JSValue obj;
/* allocate meta_obj only if requested to save memory */
obj = m->meta_obj;
if (JS_IsUndefined(obj)) {
obj = JS_NewObjectProto(ctx, JS_NULL);
if (JS_IsException(obj))
return JS_EXCEPTION;
m->meta_obj = obj;
}
return JS_DupValue(ctx, obj);
}
static JSValue js_import_meta(JSContext *ctx)
{
JSAtom filename;
JSModuleDef *m;
JSValue obj;
filename = js_get_script_or_module_name(ctx);
if (filename == JS_ATOM_NULL)
@ -26203,15 +26223,7 @@ static JSValue js_import_meta(JSContext *ctx)
JS_ThrowTypeError(ctx, "import.meta not supported in this context");
return JS_EXCEPTION;
}
/* allocate meta_obj only if requested to save memory */
obj = m->meta_obj;
if (JS_IsUndefined(obj)) {
obj = JS_NewObjectProto(ctx, JS_NULL);
if (JS_IsException(obj))
return JS_EXCEPTION;
m->meta_obj = obj;
}
return JS_DupValue(ctx, obj);
return JS_GetImportMeta(ctx, m);
}
static JSValue js_dynamic_import(JSContext *ctx, JSValueConst specifier)
@ -26252,7 +26264,7 @@ static JSValue js_dynamic_import(JSContext *ctx, JSValueConst specifier)
/* Evaluate the module code */
func_obj = JS_DupValue(ctx, JS_MKPTR(JS_TAG_MODULE, m));
ret = JS_EvalFunction(ctx, func_obj, ctx->global_obj);
ret = JS_EvalFunction(ctx, func_obj);
if (JS_IsException(ret))
goto exception;
JS_FreeValue(ctx, ret);
@ -31386,9 +31398,9 @@ static JSValue JS_EvalFunctionInternal(JSContext *ctx, JSValue fun_obj,
return ret_val;
}
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj, JSValueConst this_obj)
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj)
{
return JS_EvalFunctionInternal(ctx, fun_obj, this_obj, NULL, NULL);
return JS_EvalFunctionInternal(ctx, fun_obj, ctx->global_obj, NULL, NULL);
}
static void skip_shebang(JSParseState *s)
@ -31565,27 +31577,16 @@ JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
return ret;
}
JSValue JS_EvalBinary(JSContext *ctx,
const uint8_t *buf, size_t buf_len, int flags)
int JS_ResolveModule(JSContext *ctx, JSValueConst obj)
{
JSValue obj;
obj = JS_ReadObject(ctx, buf, buf_len, JS_READ_OBJ_BYTECODE);
if (JS_IsException(obj))
return obj;
if (flags & JS_EVAL_BINARY_LOAD_ONLY) {
return obj;
} else {
/* if a module, we load the dependencies here */
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
JSModuleDef *m = JS_VALUE_GET_PTR(obj);
if (js_resolve_module(ctx, m) < 0) {
JS_FreeValue(ctx, obj);
js_free_modules(ctx, JS_FREE_MODULE_NOT_RESOLVED);
return JS_EXCEPTION;
}
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
JSModuleDef *m = JS_VALUE_GET_PTR(obj);
if (js_resolve_module(ctx, m) < 0) {
js_free_modules(ctx, JS_FREE_MODULE_NOT_RESOLVED);
return -1;
}
return JS_EvalFunction(ctx, obj, ctx->global_obj);
}
return 0;
}
/*******************************************************************/
@ -34748,7 +34749,7 @@ static int patch_function_constructor_source(JSContext *ctx,
return 0;
}
/* XXX: add a specific eval mode so that Function("}), ({") is rejected */
static JSValue js_function_constructor(JSContext *ctx, JSValueConst new_target,
int argc, JSValueConst *argv, int magic)
{
@ -41368,18 +41369,6 @@ static JSValue JS_ToQuotedStringFree(JSContext *ctx, JSValue val) {
return r;
}
static JSValue js_json_unbox(JSContext *ctx, JSValue val) {
if (JS_IsObject(val)) {
JSObject *p = JS_VALUE_GET_OBJ(val);
if (p->class_id == JS_CLASS_STRING || p->class_id == JS_CLASS_NUMBER) {
JSValue r = JS_DupValue(ctx, p->u.object_data);
JS_FreeValue(ctx, val);
val = r;
}
}
return val;
}
#ifdef CONFIG_BIGNUM
static inline BOOL JS_IsBigInt(JSContext *ctx, JSValueConst v);
#endif
@ -41449,13 +41438,14 @@ exception:
static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
JSValueConst holder, JSValue val,
JSValueConst key, JSValueConst indent)
JSValueConst indent)
{
JSValue indent1, sep, sep1, tab, v, prop;
JSObject *p;
int64_t i, len;
int cl, res;
int cl, ret;
BOOL has_content;
indent1 = JS_UNDEFINED;
sep = JS_UNDEFINED;
sep1 = JS_UNDEFINED;
@ -41467,15 +41457,22 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
p = JS_VALUE_GET_OBJ(val);
cl = p->class_id;
if (cl == JS_CLASS_STRING) {
val = JS_InvokeFree(ctx, val, JS_ATOM_toString, 0, NULL);
val = JS_ToStringFree(ctx, val);
if (JS_IsException(val))
goto exception;
val = JS_ToQuotedStringFree(ctx, val);
if (JS_IsException(val))
goto exception;
return string_buffer_concat_value_free(jsc->b, val);
} else if (cl == JS_CLASS_NUMBER || cl == JS_CLASS_BOOLEAN) {
} else if (cl == JS_CLASS_NUMBER) {
val = JS_ToNumberFree(ctx, val);
if (JS_IsException(val))
goto exception;
return string_buffer_concat_value_free(jsc->b, val);
} else if (cl == JS_CLASS_BOOLEAN) {
ret = string_buffer_concat_value(jsc->b, p->u.object_data);
JS_FreeValue(ctx, val);
return ret;
}
#ifdef CONFIG_BIGNUM
else if (cl == JS_CLASS_BIG_FLOAT) {
@ -41485,10 +41482,10 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
goto exception;
}
#endif
res = JS_ToBoolFree(ctx, js_array_includes(ctx, jsc->stack, 1, (JSValueConst *)&val));
if (res < 0)
v = js_array_includes(ctx, jsc->stack, 1, (JSValueConst *)&val);
if (JS_IsException(v))
goto exception;
if (res) {
if (JS_ToBoolFree(ctx, v)) {
JS_ThrowTypeError(ctx, "circular reference");
goto exception;
}
@ -41509,7 +41506,10 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
v = js_array_push(ctx, jsc->stack, 1, (JSValueConst *)&val, 0);
if (check_exception_free(ctx, v))
goto exception;
if (JS_IsArray(ctx, val)) {
ret = JS_IsArray(ctx, val);
if (ret < 0)
goto exception;
if (ret) {
if (js_get_length64(ctx, &len, val))
goto exception;
string_buffer_putc8(jsc->b, '[');
@ -41520,12 +41520,18 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
v = JS_GetPropertyInt64(ctx, val, i);
if (JS_IsException(v))
goto exception;
v = js_json_check(ctx, jsc, val, v, JS_NewInt32(ctx, i));
/* XXX: could do this string conversion only when needed */
prop = JS_ToStringFree(ctx, JS_NewInt64(ctx, i));
if (JS_IsException(prop))
goto exception;
v = js_json_check(ctx, jsc, val, v, prop);
JS_FreeValue(ctx, prop);
prop = JS_UNDEFINED;
if (JS_IsException(v))
goto exception;
if (JS_IsUndefined(v))
v = JS_NULL;
if (js_json_to_str(ctx, jsc, val, v, JS_NewInt32(ctx, i), indent1))
if (js_json_to_str(ctx, jsc, val, v, indent1))
goto exception;
}
if (len > 0 && !JS_IsEmptyString(jsc->gap)) {
@ -41543,6 +41549,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
if (js_get_length64(ctx, &len, tab))
goto exception;
string_buffer_putc8(jsc->b, '{');
has_content = FALSE;
for(i = 0; i < len; i++) {
JS_FreeValue(ctx, prop);
prop = JS_GetPropertyInt64(ctx, tab, i);
@ -41555,7 +41562,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
if (JS_IsException(v))
goto exception;
if (!JS_IsUndefined(v)) {
if (i > 0)
if (has_content)
string_buffer_putc8(jsc->b, ',');
prop = JS_ToQuotedStringFree(ctx, prop);
if (JS_IsException(prop)) {
@ -41566,11 +41573,12 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
string_buffer_concat_value(jsc->b, prop);
string_buffer_putc8(jsc->b, ':');
string_buffer_concat_value(jsc->b, sep1);
if (js_json_to_str(ctx, jsc, val, v, prop, indent1))
if (js_json_to_str(ctx, jsc, val, v, indent1))
goto exception;
has_content = TRUE;
}
}
if (len > 0 && JS_VALUE_GET_STRING(jsc->gap)->len != 0) {
if (has_content && JS_VALUE_GET_STRING(jsc->gap)->len != 0) {
string_buffer_putc8(jsc->b, '\n');
string_buffer_concat_value(jsc->b, indent);
}
@ -41589,14 +41597,19 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
val = JS_ToQuotedStringFree(ctx, val);
if (JS_IsException(val))
goto exception;
/* fall thru */
case JS_TAG_INT:
goto concat_value;
case JS_TAG_FLOAT64:
if (!isfinite(JS_VALUE_GET_FLOAT64(val))) {
val = JS_NULL;
}
goto concat_value;
case JS_TAG_INT:
#ifdef CONFIG_BIGNUM
case JS_TAG_BIG_FLOAT:
#endif
case JS_TAG_BOOL:
case JS_TAG_NULL:
concat_value:
return string_buffer_concat_value_free(jsc->b, val);
#ifdef CONFIG_BIGNUM
case JS_TAG_BIG_INT:
@ -41625,7 +41638,7 @@ static JSValue js_json_stringify(JSContext *ctx, JSValueConst this_val,
StringBuffer b_s;
JSONStringifyContext jsc_s, *jsc = &jsc_s;
JSValueConst replacer = argv[1];
JSValue val, v, space, ret;
JSValue val, v, space, ret, wrapper;
int res;
int64_t i, j, n;
@ -41636,6 +41649,7 @@ static JSValue js_json_stringify(JSContext *ctx, JSValueConst this_val,
jsc->b = &b_s;
jsc->empty = JS_AtomToString(ctx, JS_ATOM_empty_string);
ret = JS_UNDEFINED;
wrapper = JS_UNDEFINED;
string_buffer_init(ctx, jsc->b, 0);
jsc->stack = JS_NewArray(ctx);
@ -41655,21 +41669,56 @@ static JSValue js_json_stringify(JSContext *ctx, JSValueConst this_val,
if (js_get_length64(ctx, &n, replacer))
goto exception;
for (i = j = 0; i < n; i++) {
JSValue present;
v = JS_GetPropertyInt64(ctx, replacer, i);
if (JS_IsException(v))
goto exception;
v = js_json_unbox(ctx, v);
if (JS_IsNumber(v)) {
if (JS_IsObject(v)) {
JSObject *p = JS_VALUE_GET_OBJ(v);
if (p->class_id == JS_CLASS_STRING ||
p->class_id == JS_CLASS_NUMBER) {
v = JS_ToStringFree(ctx, v);
if (JS_IsException(v))
goto exception;
} else {
JS_FreeValue(ctx, v);
continue;
}
} else if (JS_IsNumber(v)) {
v = JS_ToStringFree(ctx, v);
if (JS_IsException(v))
goto exception;
} else if (!JS_IsString(v)) {
JS_FreeValue(ctx, v);
continue;
}
JS_SetPropertyInt64(ctx, jsc->property_list, j++, v);
present = js_array_includes(ctx, jsc->property_list,
1, (JSValueConst *)&v);
if (JS_IsException(present)) {
JS_FreeValue(ctx, v);
goto exception;
}
if (!JS_ToBoolFree(ctx, present)) {
JS_SetPropertyInt64(ctx, jsc->property_list, j++, v);
} else {
JS_FreeValue(ctx, v);
}
}
}
}
space = js_json_unbox(ctx, JS_DupValue(ctx, argv[2]));
space = JS_DupValue(ctx, argv[2]);
if (JS_IsObject(space)) {
JSObject *p = JS_VALUE_GET_OBJ(space);
if (p->class_id == JS_CLASS_NUMBER) {
space = JS_ToNumberFree(ctx, space);
} else if (p->class_id == JS_CLASS_STRING) {
space = JS_ToStringFree(ctx, space);
}
if (JS_IsException(space)) {
JS_FreeValue(ctx, space);
goto exception;
}
}
if (JS_IsNumber(space)) {
int n;
if (JS_ToInt32Clamp(ctx, &n, space, 0, 10, 0))
@ -41684,15 +41733,22 @@ static JSValue js_json_stringify(JSContext *ctx, JSValueConst this_val,
JS_FreeValue(ctx, space);
if (JS_IsException(jsc->gap))
goto exception;
wrapper = JS_NewObject(ctx);
if (JS_IsException(wrapper))
goto exception;
if (JS_DefinePropertyValue(ctx, wrapper, JS_ATOM_empty_string,
JS_DupValue(ctx, argv[0]), JS_PROP_C_W_E) < 0)
goto exception;
val = JS_DupValue(ctx, argv[0]);
val = js_json_check(ctx, jsc, JS_NULL, val, jsc->empty);
val = js_json_check(ctx, jsc, wrapper, val, jsc->empty);
if (JS_IsException(val))
goto exception;
if (JS_IsUndefined(val)) {
ret = JS_UNDEFINED;
goto done1;
}
if (js_json_to_str(ctx, jsc, JS_NULL, val, jsc->empty, jsc->empty))
if (js_json_to_str(ctx, jsc, wrapper, val, jsc->empty))
goto exception;
ret = string_buffer_end(jsc->b);
@ -41703,6 +41759,7 @@ exception:
done1:
string_buffer_free(jsc->b);
done:
JS_FreeValue(ctx, wrapper);
JS_FreeValue(ctx, jsc->empty);
JS_FreeValue(ctx, jsc->gap);
JS_FreeValue(ctx, jsc->property_list);
@ -44730,25 +44787,23 @@ static const JSCFunctionListEntry js_async_function_proto_funcs[] = {
JS_PROP_STRING_DEF("[Symbol.toStringTag]", "AsyncFunction", JS_PROP_CONFIGURABLE ),
};
static JSValue js_async_from_async_iterator_unwrap(JSContext *ctx,
JSValueConst this_val,
int argc, JSValueConst *argv,
int magic, JSValue *func_data)
static JSValue js_async_from_sync_iterator_unwrap(JSContext *ctx,
JSValueConst this_val,
int argc, JSValueConst *argv,
int magic, JSValue *func_data)
{
return js_create_iterator_result(ctx, JS_DupValue(ctx, func_data[0]),
JS_ToBool(ctx, func_data[1]));
return js_create_iterator_result(ctx, JS_DupValue(ctx, argv[0]),
JS_ToBool(ctx, func_data[0]));
}
static JSValue js_async_from_async_iterator_unwrap_func_create(JSContext *ctx,
JSValueConst value,
BOOL done)
static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx,
BOOL done)
{
JSValueConst func_data[2];
JSValueConst func_data[1];
func_data[0] = value;
func_data[1] = (JSValueConst)JS_NewBool(ctx, done);
return JS_NewCFunctionData(ctx, js_async_from_async_iterator_unwrap,
0, 0, 2, func_data);
func_data[0] = (JSValueConst)JS_NewBool(ctx, done);
return JS_NewCFunctionData(ctx, js_async_from_sync_iterator_unwrap,
1, 0, 1, func_data);
}
/* AsyncIteratorPrototype */
@ -44886,7 +44941,8 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValueConst thi
goto reject;
}
resolve_reject[0] = js_async_from_async_iterator_unwrap_func_create(ctx, value, done);
resolve_reject[0] =
js_async_from_sync_iterator_unwrap_func_create(ctx, done);
if (JS_IsException(resolve_reject[0])) {
JS_FreeValue(ctx, value_wrapper_promise);
goto fail;
@ -47234,6 +47290,10 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
/* global properties */
JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_global_funcs,
countof(js_global_funcs));
JS_DefinePropertyValue(ctx, ctx->global_obj, JS_ATOM_globalThis,
JS_DupValue(ctx, ctx->global_obj),
JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE);
}
/* Typed Arrays */
@ -48630,7 +48690,7 @@ static int js_cmp_doubles(double x, double y)
if (x > y) return 1;
if (x != 0) return 0;
if (signbit(x)) return signbit(y) ? 0 : -1;
else return signbit(y) ? -1 : 0;
else return signbit(y) ? 1 : 0;
}
static int js_TA_cmp_int8(const void *a, const void *b, void *opaque) {

+ 11
- 5
quickjs.h View File

@ -279,7 +279,10 @@ static inline JSValue __JS_NewFloat64(JSContext *ctx, double d)
#define JS_EVAL_FLAG_STRICT (1 << 3) /* force 'strict' mode */
#define JS_EVAL_FLAG_STRIP (1 << 4) /* force 'strip' mode */
#define JS_EVAL_FLAG_COMPILE_ONLY (1 << 5) /* internal use */
/* compile but do not run. The result is an object with a
JS_TAG_FUNCTION_BYTECODE or JS_TAG_MODULE tag. It can be executed
with JS_EvalFunction(). */
#define JS_EVAL_FLAG_COMPILE_ONLY (1 << 5)
typedef JSValue JSCFunction(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv);
typedef JSValue JSCFunctionMagic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic);
@ -694,9 +697,7 @@ JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
JS_BOOL JS_DetectModule(const char *input, size_t input_len);
JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
const char *filename, int eval_flags);
#define JS_EVAL_BINARY_LOAD_ONLY (1 << 0) /* only load the module */
JSValue JS_EvalBinary(JSContext *ctx,
const uint8_t *buf, size_t buf_len, int flags);
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj);
JSValue JS_GetGlobalObject(JSContext *ctx);
int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj);
int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
@ -746,6 +747,9 @@ typedef JSModuleDef *JSModuleLoaderFunc(JSContext *ctx,
void JS_SetModuleLoaderFunc(JSRuntime *rt,
JSModuleNormalizeFunc *module_normalize,
JSModuleLoaderFunc *module_loader, void *opaque);
/* return the import.meta object of a module */
JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m);
JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
/* JS Job support */
@ -764,7 +768,9 @@ uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValueConst obj,
#define JS_READ_OBJ_ROM_DATA (1 << 1) /* avoid duplicating 'buf' data */
JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
int flags);
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj, JSValueConst this_obj);
/* load the dependencies of the module 'obj'. Useful when JS_ReadObject()
returns a module. */
int JS_ResolveModule(JSContext *ctx, JSValueConst obj);
/* C function definition */
typedef enum JSCFunctionEnum { /* XXX: should rename for namespace isolation */

+ 2
- 2
release.sh View File

@ -80,14 +80,14 @@ outdir="/tmp/${d}"
rm -rf $outdir
mkdir -p $outdir
files="qjs qjsbn run-test262 run-test262-bn "
files="qjs qjsbn run-test262 run-test262-bn"
make -j4 $files
strip $files
cp $files $outdir
( cd /tmp && tar Jcvf /tmp/${name}.tar.xz ${d} )
( cd /tmp/$d && rm -f ../${name}.zip && zip -r ../${name}.zip . )
fi

+ 1
- 4
repl.js View File

@ -28,9 +28,6 @@ import * as std from "std";
import * as os from "os";
(function(g) {
/* add a 'global' binding */
g.global = std.global;
/* add 'os' and 'std' bindings */
g.os = os;
g.std = std;
@ -1507,4 +1504,4 @@ import * as os from "os";
cmd_start();
})(std.global);
})(globalThis);

+ 2
- 6
run-test262.c View File

@ -750,11 +750,6 @@ static JSValue add_helpers1(JSContext *ctx)
JS_SetPropertyStr(ctx, global_obj, "print",
JS_NewCFunction(ctx, js_print, "print", 1));
/* add it in the engine once the proposal is accepted */
JS_DefinePropertyValueStr(ctx, global_obj, "globalThis",
JS_DupValue(ctx, global_obj),
JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE);
/* $262 special object used by the tests */
obj262 = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, obj262, "detachArrayBuffer",
@ -1910,7 +1905,8 @@ void run_test_dir_list(namelist_t *lp, int start_index, int stop_index)
void help(void)
{
printf("usage: run-test262 [options] {-f file ... | [dir_list] [index range]}\n"
printf("run-test262 version " CONFIG_VERSION "\n"
"usage: run-test262 [options] {-f file ... | [dir_list] [index range]}\n"
"-h help\n"
"-a run tests in strict and nostrict modes\n"
"-m print memory usage summary\n"

+ 0
- 7
test262.conf View File

@ -171,13 +171,6 @@ test262/test/built-ins/BigInt/
test262/test/built-ins/Function/prototype/restricted-property-caller.js
test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js
# no debugger keyword support
test262/test/language/statements/debugger/statement.js
# bogus tests
test262/test/language/expressions/dynamic-import/for-await-resolution-and-error-agen.js
test262/test/language/expressions/dynamic-import/for-await-resolution-and-error.js
# slow tests
#test262/test/built-ins/RegExp/CharacterClassEscapes/
#test262/test/built-ins/RegExp/property-escapes/

+ 0
- 7
test262bn.conf View File

@ -169,13 +169,6 @@ test262/test/intl402/
test262/test/built-ins/Function/prototype/restricted-property-caller.js
test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js
# no debugger keyword support
test262/test/language/statements/debugger/statement.js
# bogus tests
test262/test/language/expressions/dynamic-import/for-await-resolution-and-error-agen.js
test262/test/language/expressions/dynamic-import/for-await-resolution-and-error.js
# slow tests
#test262/test/built-ins/RegExp/CharacterClassEscapes/
#test262/test/built-ins/RegExp/property-escapes/

+ 50
- 1
tests/test262.patch View File

@ -69,6 +69,29 @@ index 2abfee3..e7c07b1 100644
}
function testPropertyEscapes(regex, string, expression) {
diff --git a/test/built-ins/TypedArray/prototype/sort/sorted-values.js b/test/built-ins/TypedArray/prototype/sort/sorted-values.js
index 83d870e..85a9bcd 100644
--- a/test/built-ins/TypedArray/prototype/sort/sorted-values.js
+++ b/test/built-ins/TypedArray/prototype/sort/sorted-values.js
@@ -25,9 +25,6 @@ testWithTypedArrayConstructors(function(TA) {
sample = new TA([3, 4, 3, 1, 0, 1, 2]).sort();
assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers");
-
- sample = new TA([1, 0, -0, 2]).sort();
- assert(compareArray(sample, [0, 0, 1, 2]), "0s");
});
testWithTypedArrayConstructors(function(TA) {
@@ -45,7 +42,7 @@ testWithTypedArrayConstructors(function(TA) {
assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives");
sample = new TA([1, 0, -0, 2]).sort();
- assert(compareArray(sample, [0, 0, 1, 2]), "0 and -0");
+ assert(compareArray(sample, [-0, 0, 1, 2]), "0 and -0");
sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort();
assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities");
diff --git a/test/language/expressions/class/private-getter-brand-check-multiple-evaluations-of-class-realm-function-ctor.js b/test/language/expressions/class/private-getter-brand-check-multiple-evaluations-of-class-realm-function-ctor.js
index 48ed9a8..f486a2c 100644
--- a/test/language/expressions/class/private-getter-brand-check-multiple-evaluations-of-class-realm-function-ctor.js
@ -160,8 +183,21 @@ index 0c12f51..b59d32a 100644
flags: [noStrict]
---*/
diff --git a/test/language/expressions/class/private-static-getter-multiple-evaluations-of-class-realm.js b/test/language/expressions/class/private-static-getter-multiple-evaluations-of-class-realm.js
index 79b0920..e97e326 100644
--- a/test/language/expressions/class/private-static-getter-multiple-evaluations-of-class-realm.js
+++ b/test/language/expressions/class/private-static-getter-multiple-evaluations-of-class-realm.js
@@ -19,7 +19,7 @@ info: |
PrivateBrandCheck(O, P)
1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true,
a. Throw a TypeError exception.
-features: [class, class-static-methods-private]
+features: [class, class-static-methods-private, cross-realm]
flags: [noStrict]
---*/
diff --git a/test/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-realm.js b/test/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-realm.js
index 3ada7fe..7d8f0a2 100644
index b5e25b9..bfef8f6 100644
--- a/test/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-realm.js
+++ b/test/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-realm.js
@@ -19,7 +19,7 @@ info: |
@ -173,3 +209,16 @@ index 3ada7fe..7d8f0a2 100644
flags: [noStrict]
---*/
diff --git a/test/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js b/test/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js
index acaf7cf..412d37a 100644
--- a/test/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js
+++ b/test/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js
@@ -19,7 +19,7 @@ info: |
PrivateBrandCheck(O, P)
1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true,
a. Throw a TypeError exception.
-features: [class, class-static-methods-private]
+features: [class, class-static-methods-private, cross-realm]
flags: [noStrict]
---*/

Loading…
Cancel
Save