From 15c572436bdcb355b6222814f6e8300c0f927700 Mon Sep 17 00:00:00 2001 From: Patrick Soquet Date: Wed, 20 Nov 2019 17:06:01 +0100 Subject: [PATCH] XS: 9.0.2 for the sake of xst, eshost and test262-harness - REBUILD ALL --- documentation/xs/XS Conformance.md | 64 ++++++---- xs/sources/xsCommon.h | 2 +- xs/tools/xst.c | 183 +++++++++++++++-------------- 3 files changed, 135 insertions(+), 114 deletions(-) diff --git a/documentation/xs/XS Conformance.md b/documentation/xs/XS Conformance.md index 1b180be59a..23274af4a0 100644 --- a/documentation/xs/XS Conformance.md +++ b/documentation/xs/XS Conformance.md @@ -2,7 +2,7 @@ Copyright 2016-2019 Moddable Tech, Inc. -Revised: November 5, 2019 +Revised: November 20, 2019 ## Caveat @@ -67,11 +67,11 @@ After the 6th edition, TC39 adopted a [process](https://tc39.github.io/process-d The official conformance test suite, [test262](https://github.com/tc39/test262), contains cases for the published specifications, together with cases for proposals at stages 3 and 4, which is great to prepare XS for future editions. The XS harness, `xst` uses adhoc comparisons of the frontmatter `[features]` to skip cases related to not yet implemented proposals. See the skipped cases at the end of this document. -Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) and **99.8%** of the built-ins tests (`29925/29998`). Details are here under. The numbers of skipped cases are between parentheses. The following section lists the failed tests with some explanations. +Currently, on macOS, XS passes **99.8%** of the language tests (`38847/38911`) and **99.8%** of the built-ins tests (`29925/29998`). Details are here under. The numbers of skipped cases are between parentheses. The following section lists the failed tests with some explanations. ### Language - 99% 38857/38959 (33) language + 99% 38847/38911 (58) language 100% 457/457 arguments-object 100% 40/40 mapped 100% 8/8 unmapped @@ -106,7 +106,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 139/139 direct 98% 114/116 indirect 100% 3/3 export - 99% 18111/18189 (24) expressions + 99% 18100/18141 (49) expressions 100% 95/95 addition 100% 104/104 array 100% 617/617 arrow-function @@ -154,15 +154,15 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 50/50 gen-method-static 100% 30/30 method 100% 30/30 method-static - 17% 8/46 coalesce + 0% 0/0 (24) coalesce 100% 11/11 comma 99% 699/701 compound-assignment 100% 10/10 concatenation - 95% 40/42 conditional + 100% 40/40 (1) conditional 100% 85/85 delete 100% 89/89 division 100% 75/75 does-not-equals - 99% 997/999 dynamic-import + 99% 994/999 dynamic-import 100% 53/53 assignment-expression 100% 208/208 catch 100% 116/116 namespace @@ -246,7 +246,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 22/22 rest-parameters 0% 0/2 source-text 100% 160/160 statementList - 99% 16463/16480 (9) statements + 99% 16464/16480 (9) statements 100% 113/113 async-function 100% 566/566 async-generator 100% 360/360 dstr @@ -340,7 +340,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 127/127 syntax 100% 127/127 redeclaration 100% 28/28 throw - 99% 369/370 try + 100% 370/370 try 100% 180/180 dstr 100% 291/291 variable 100% 180/180 dstr @@ -359,7 +359,10 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a ### Built-ins - 99% 29925/29998 (20) built-ins + 99% 29956/30034 (88) built-ins + 0% 0/0 (29) AggregateError + 0% 0/0 (14) prototype + 0% 0/0 (9) errors 99% 5197/5209 Array 100% 8/8 Symbol.species 100% 80/80 from @@ -421,7 +424,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 32/32 throw 100% 8/8 AsyncIteratorPrototype 100% 8/8 Symbol.asyncIterator - 99% 471/472 (7) Atomics + 99% 470/472 (7) Atomics 100% 26/26 add 100% 6/6 bigint 100% 26/26 and @@ -442,7 +445,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 6/6 bigint 100% 26/26 sub 100% 6/6 bigint - 99% 137/138 (7) wait + 98% 136/138 (7) wait 97% 45/46 (2) bigint 100% 26/26 xor 100% 6/6 bigint @@ -538,11 +541,11 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 6/6 message 100% 6/6 name 100% 20/20 toString - 98% 132/134 FinalizationGroup + 95% 128/134 FinalizationGroup 100% 16/16 FinalizationGroupCleanupIteratorPrototype - 100% 86/86 prototype + 95% 82/86 prototype 100% 32/32 cleanupSome - 100% 30/30 register + 86% 26/30 register 100% 16/16 unregister 99% 893/895 Function 100% 16/16 internals @@ -565,8 +568,8 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 10/10 Infinity 100% 8/8 IteratorPrototype 100% 8/8 Symbol.iterator - 100% 262/262 JSON - 100% 124/124 parse + 100% 276/276 JSON + 100% 138/138 parse 100% 126/126 stringify 100% 286/286 Map 100% 8/8 Symbol.species @@ -657,7 +660,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 30/30 toPrecision 100% 98/98 toString 100% 20/20 valueOf - 100% 6216/6216 Object + 100% 6234/6234 Object 100% 52/52 assign 100% 638/638 create 100% 1242/1242 defineProperties @@ -667,8 +670,8 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 48/48 fromEntries 100% 614/614 getOwnPropertyDescriptor 100% 30/30 getOwnPropertyDescriptors - 100% 74/74 getOwnPropertyNames - 100% 8/8 getOwnPropertySymbols + 100% 82/82 getOwnPropertyNames + 100% 16/16 getOwnPropertySymbols 100% 76/76 getPrototypeOf 100% 12/12 internals 100% 12/12 DefineOwnProperty @@ -676,7 +679,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 74/74 isExtensible 100% 114/114 isFrozen 100% 62/62 isSealed - 100% 108/108 keys + 100% 110/110 keys 100% 72/72 preventExtensions 100% 338/338 prototype 100% 4/4 constructor @@ -700,7 +703,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 156/156 race 100% 28/28 reject 100% 58/58 resolve - 100% 505/505 Proxy + 100% 509/509 Proxy 100% 22/22 apply 100% 52/52 construct 100% 42/42 defineProperty @@ -709,12 +712,12 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 32/32 get 100% 36/36 getOwnPropertyDescriptor 100% 32/32 getPrototypeOf - 100% 35/35 has + 100% 37/37 has 100% 18/18 isExtensible 100% 48/48 ownKeys 100% 18/18 preventExtensions 100% 22/22 revocable - 100% 42/42 set + 100% 44/44 set 100% 28/28 setPrototypeOf 100% 274/274 Reflect 100% 14/14 apply @@ -779,10 +782,10 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 100% 84/84 prototype 100% 18/18 byteLength 100% 62/62 slice - 99% 2115/2131 String + 99% 2115/2131 (39) String 100% 28/28 fromCharCode 100% 20/20 fromCodePoint - 99% 1830/1844 prototype + 99% 1830/1844 (39) prototype 100% 10/10 Symbol.iterator 100% 58/58 charAt 100% 48/48 charCodeAt @@ -801,6 +804,7 @@ Currently, on macOS, XS passes **99.8%** of the language tests (`38857/38959`) a 91% 22/24 padStart 100% 30/30 repeat 100% 90/90 replace + 0% 0/0 (39) replaceAll 100% 70/70 search 100% 70/70 slice 100% 214/214 split @@ -1065,6 +1069,11 @@ Test uses Annex B `__lookupGetter__`. XS optimizes modulus for integer values, which fails for -1 % -1 == -0. + language/expressions/dynamic-import/eval-self-once-module.js + language/expressions/dynamic-import/eval-self-once-script.js + +A module cannot dynamically imports itself. + language/expressions/dynamic-import/for-await-resolution-and-error-agen-yield.js ? @@ -1149,6 +1158,8 @@ Code points vs code units. One realm. built-ins/FinalizationGroup/gc-has-one-chance-to-call-cleanupCallback.js + built-ins/FinalizationGroup/prototype/register/holdings-same-as-target.js + built-ins/FinalizationGroup/prototype/register/unregisterToken-same-as-holdings-and-target.js ? @@ -1210,6 +1221,7 @@ Code points vs code units. ### Skipped cases + AggregateError coalesce-expression optional-chaining regexp-match-indices diff --git a/xs/sources/xsCommon.h b/xs/sources/xsCommon.h index 2bda8311a8..a954443103 100644 --- a/xs/sources/xsCommon.h +++ b/xs/sources/xsCommon.h @@ -95,7 +95,7 @@ typedef struct { #define XS_ATOM_VERSION 0x56455253 /* 'VERS' */ #define XS_MAJOR_VERSION 9 #define XS_MINOR_VERSION 0 -#define XS_PATCH_VERSION 1 +#define XS_PATCH_VERSION 2 #define XS_DIGEST_SIZE 16 #define XS_VERSION_SIZE 4 diff --git a/xs/tools/xst.c b/xs/tools/xst.c index 795d662ce9..0356c7615a 100644 --- a/xs/tools/xst.c +++ b/xs/tools/xst.c @@ -132,6 +132,7 @@ struct sxResult { static int main262(int argc, char* argv[]); +static void fxBuildAgent(xsMachine* the); static void fxCountResult(txContext* context, int success, int pending); static yaml_node_t *fxGetMappingValue(yaml_document_t* document, yaml_node_t* mapping, char* name); static void fxPopResult(txContext* context); @@ -140,9 +141,11 @@ static void fxPrintUsage(); static void fxPushResult(txContext* context, char* path); static void fxRunDirectory(txContext* context, char* path); static void fxRunFile(txContext* context, char* path); -static int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* message); +static int fxRunTestCase(txContext* context, char* path, txUnsigned flags, int async, char* message); static int fxStringEndsWith(const char *string, const char *suffix); +static void fx_agent_get_safeBroadcast(xsMachine* the); +static void fx_agent_set_safeBroadcast(xsMachine* the); static void fx_agent_broadcast(xsMachine* the); static void fx_agent_getReport(xsMachine* the); static void fx_agent_leaving(xsMachine* the); @@ -159,11 +162,10 @@ static void* fx_agent_start_aux(void* it); static void fx_agent_stop(xsMachine* the); extern void fx_clearTimer(txMachine* the); static void fx_createRealm(xsMachine* the); -static void fx_createRealmException(xsMachine* the); static void fx_detachArrayBuffer(xsMachine* the); -static void fx_gc(xsMachine* the); static void fx_done(xsMachine* the); static void fx_evalScript(xsMachine* the); +static void fx_gc(xsMachine* the); static void fx_print(xsMachine* the); static void fx_setInterval(txMachine* the); static void fx_setTimeout(txMachine* the); @@ -178,7 +180,6 @@ static void fx_destroyTimer(void* data); static void fx_markTimer(txMachine* the, void* it, txMarkRoot markRoot); static void fx_setTimerCallback(txJob* job); - static txAgentCluster gxAgentCluster; int main(int argc, char* argv[]) @@ -238,22 +239,12 @@ int main(int argc, char* argv[]) }; xsCreation* creation = &_creation; xsMachine* machine; + fxInitializeSharedCluster(); machine = xsCreateMachine(creation, "xsr", NULL); xsBeginHost(machine); { xsTry { - txSlot* slot; - mxPush(mxGlobal); - slot = fxLastProperty(the, fxToInstance(the, the->stack)); - slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearInterval"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearTimeout"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_createRealmException, 1, xsID("createRealm"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_evalScript, 1, xsID("evalScript"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_print, 1, xsID("print"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_setInterval, 1, xsID("setInterval"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_setTimeout, 1, xsID("setTimeout"), XS_DONT_ENUM_FLAG); - mxPop(); - + fxBuildAgent(the); for (argi = 1; argi < argc; argi++) { if (argv[argi][0] == '-') continue; @@ -273,12 +264,19 @@ int main(int argc, char* argv[]) } } xsCatch { + } + } + xsEndHost(machine); + fxRunLoop(machine); + xsBeginHost(machine); + { + if (xsTypeOf(xsException) != xsUndefinedType) { fprintf(stderr, "%s\n", xsToString(xsException)); error = 1; } } xsEndHost(machine); - fxRunLoop(machine); + fxTerminateSharedCluster(); xsDeleteMachine(machine); } return error; @@ -382,6 +380,45 @@ int main262(int argc, char* argv[]) return error; } +void fxBuildAgent(xsMachine* the) +{ + txSlot* slot; + txSlot* agent; + txSlot* global; + + slot = fxLastProperty(the, fxNewHostObject(the, NULL)); + slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_agent_get_safeBroadcast), mxCallback(fx_agent_set_safeBroadcast), xsID("safeBroadcast"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_agent_broadcast, 2, xsID("broadcast"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_agent_getReport, 0, xsID("getReport"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_agent_sleep, 1, xsID("sleep"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_agent_start, 1, xsID("start"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_agent_stop, 1, xsID("stop"), XS_DONT_ENUM_FLAG); + agent = the->stack; + + mxPush(mxGlobal); + global = the->stack; + + mxPush(mxObjectPrototype); + slot = fxLastProperty(the, fxNewObjectInstance(the)); + slot = fxNextSlotProperty(the, slot, agent, xsID("agent"), XS_GET_ONLY); + slot = fxNextHostFunctionProperty(the, slot, fx_createRealm, 0, xsID("createRealm"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_detachArrayBuffer, 1, xsID("detachArrayBuffer"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_gc, 1, xsID("gc"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_evalScript, 1, xsID("evalScript"), XS_DONT_ENUM_FLAG); + slot = fxNextSlotProperty(the, slot, global, xsID("global"), XS_GET_ONLY); + + slot = fxLastProperty(the, fxToInstance(the, global)); + slot = fxNextSlotProperty(the, slot, the->stack, xsID("$262"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_print, 1, xsID("print"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearInterval"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearTimeout"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_setInterval, 1, xsID("setInterval"), XS_DONT_ENUM_FLAG); + slot = fxNextHostFunctionProperty(the, slot, fx_setTimeout, 1, xsID("setTimeout"), XS_DONT_ENUM_FLAG); + + mxPop(); + mxPop(); +} + void fxCountResult(txContext* context, int success, int pending) { txResult* result = context->current; @@ -597,6 +634,7 @@ void fxRunFile(txContext* context, char* path) yaml_document_t* document = NULL; yaml_node_t* root; yaml_node_t* value; + int async = 0; int sloppy = 1; int strict = 1; int module = 0; @@ -643,7 +681,10 @@ void fxRunFile(txContext* context, char* path) yaml_node_item_t* item = value->data.sequence.items.start; while (item < value->data.sequence.items.top) { yaml_node_t* node = yaml_document_get_node(document, *item); - if (!strcmp((char*)node->data.scalar.value, "onlyStrict")) { + if (!strcmp((char*)node->data.scalar.value, "async")) { + async = 1; + } + else if (!strcmp((char*)node->data.scalar.value, "onlyStrict")) { sloppy = 0; strict = 1; module = 0; @@ -679,7 +720,9 @@ void fxRunFile(txContext* context, char* path) yaml_node_item_t* item = value->data.sequence.items.start; while (item < value->data.sequence.items.top) { yaml_node_t* node = yaml_document_get_node(document, *item); - if (!strcmp((char*)node->data.scalar.value, "coalesce-expression") + if (!strcmp((char*)node->data.scalar.value, "AggregateError") + || !strcmp((char*)node->data.scalar.value, "String.prototype.replaceAll") + || !strcmp((char*)node->data.scalar.value, "coalesce-expression") || !strcmp((char*)node->data.scalar.value, "optional-chaining") || !strcmp((char*)node->data.scalar.value, "regexp-match-indices") #ifndef mxRegExpUnicodePropertyEscapes @@ -697,21 +740,21 @@ void fxRunFile(txContext* context, char* path) if (sloppy) { fprintf(stderr, "### %s (sloppy): ", path + context->testPathLength); - if (fxRunTestCase(context, path, mxProgramFlag | mxDebugFlag, message)) + if (fxRunTestCase(context, path, mxProgramFlag | mxDebugFlag, async, message)) fprintf(stderr, "%s\n", message); else fprintf(stderr, "%s\n", message); } if (strict) { fprintf(stderr, "### %s (strict): ", path + context->testPathLength); - if (fxRunTestCase(context, path, mxProgramFlag | mxDebugFlag | mxStrictFlag, message)) + if (fxRunTestCase(context, path, mxProgramFlag | mxDebugFlag | mxStrictFlag, async, message)) fprintf(stderr, "%s\n", message); else fprintf(stderr, "%s\n", message); } if (module) { fprintf(stderr, "### %s (module): ", path + context->testPathLength); - if (fxRunTestCase(context, path, 0, message)) + if (fxRunTestCase(context, path, 0, async, message)) fprintf(stderr, "%s\n", message); else fprintf(stderr, "%s\n", message); @@ -735,7 +778,7 @@ void fxRunFile(txContext* context, char* path) } static char gxDoneMessage[1024]; -int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* message) +int fxRunTestCase(txContext* context, char* path, txUnsigned flags, int async, char* message) { xsCreation _creation = { 16 * 1024 * 1024, /* initialChunkSize */ @@ -763,48 +806,18 @@ int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* messag xsBeginHost(machine); { xsTry { - txSlot* slot; - txSlot* agent; - txSlot* global; - - slot = fxLastProperty(the, fxNewHostObject(the, NULL)); - slot = fxNextHostFunctionProperty(the, slot, fx_agent_broadcast, 2, xsID("broadcast"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_agent_getReport, 0, xsID("getReport"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_agent_sleep, 1, xsID("sleep"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_agent_start, 1, xsID("start"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_agent_stop, 1, xsID("stop"), XS_DONT_ENUM_FLAG); - agent = the->stack; - - mxPush(mxGlobal); - global = the->stack; - - mxPush(mxObjectPrototype); - slot = fxLastProperty(the, fxNewObjectInstance(the)); - slot = fxNextSlotProperty(the, slot, agent, xsID("agent"), XS_GET_ONLY); - slot = fxNextHostFunctionProperty(the, slot, fx_createRealm, 0, xsID("createRealm"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_detachArrayBuffer, 1, xsID("detachArrayBuffer"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_gc, 1, xsID("gc"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_evalScript, 1, xsID("evalScript"), XS_DONT_ENUM_FLAG); - slot = fxNextSlotProperty(the, slot, global, xsID("global"), XS_GET_ONLY); - - slot = fxLastProperty(the, fxToInstance(the, global)); - slot = fxNextSlotProperty(the, slot, the->stack, xsID("$262"), XS_GET_ONLY); - slot = fxNextHostFunctionProperty(the, slot, fx_print, 1, xsID("print"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearInterval"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_clearTimer, 1, xsID("clearTimeout"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_setInterval, 1, xsID("setInterval"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_setTimeout, 1, xsID("setTimeout"), XS_DONT_ENUM_FLAG); - slot = fxNextHostFunctionProperty(the, slot, fx_done, 1, xsID("$DONE"), XS_DONT_ENUM_FLAG); - - mxPop(); - mxPop(); - + fxBuildAgent(the); c_strcpy(buffer, context->harnessPath); c_strcat(buffer, "sta.js"); fxRunProgramFile(the, buffer, mxProgramFlag | mxDebugFlag); c_strcpy(buffer, context->harnessPath); c_strcat(buffer, "assert.js"); fxRunProgramFile(the, buffer, mxProgramFlag | mxDebugFlag); + if (async) { + xsResult = xsNewHostFunction(fx_done, 1); + xsSet(xsGlobal, xsID("$DONE"), xsResult); + xsSet(xsGlobal, xsID("$DONE_RESULT"), xsString("Test did not run to completion")); + } if (context->includes) { yaml_node_item_t* item = context->includes->data.sequence.items.start; while (item < context->includes->data.sequence.items.top) { @@ -814,19 +827,12 @@ int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* messag fxRunProgramFile(the, buffer, mxProgramFlag | mxDebugFlag); item++; } - - mxPushSlot(agent); - fxGetID(the, xsID("broadcast")); - mxPushSlot(agent); - fxSetID(the, xsID("safeBroadcast")); - mxPop(); } mxPop(); if (flags) fxRunProgramFile(the, path, flags); else fxRunModuleFile(the, path); - xsException = xsUndefined; } xsCatch { } @@ -835,17 +841,18 @@ int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* messag fxRunLoop(machine); xsBeginHost(machine); { - if (gxDoneMessage[0]) { - if (strcmp(gxDoneMessage, "OK")) { - snprintf(message, 1024, "%s", gxDoneMessage); - } - else { - snprintf(message, 1024, "OK"); - success = 1; + if (xsTypeOf(xsException) == xsUndefinedType) { + if (async) { + xsResult = xsGet(xsGlobal, xsID("$DONE_RESULT")); + if (xsTypeOf(xsResult) == xsUndefinedType) { + snprintf(message, 1024, "OK"); + success = 1; + } + else { + snprintf(message, 1024, "# %s", xsToString(xsResult)); + } } - } - else if (xsTypeOf(xsException) == xsUndefinedType) { - if (context->negative) { + else if (context->negative) { snprintf(message, 1024, "# Expected a %s but got no errors", context->negative->data.scalar.value); } else { @@ -882,12 +889,10 @@ int fxRunTestCase(txContext* context, char* path, txUnsigned flags, char* messag void fx_done(xsMachine* the) { - if ((xsToInteger(xsArgc) == 0) || (xsTypeOf(xsArg(0)) == xsUndefinedType)) - strcpy(gxDoneMessage, "OK"); - else { - txString name = xsToString(xsArg(0)); - snprintf(gxDoneMessage, 1024, "# Async: %s", name); - } + if ((xsToInteger(xsArgc) > 0) && (xsTest(xsArg(0)))) + xsSet(xsGlobal, xsID("$DONE_RESULT"), xsArg(0)); + else + xsSet(xsGlobal, xsID("$DONE_RESULT"), xsUndefined); } int fxStringEndsWith(const char *string, const char *suffix) @@ -899,6 +904,15 @@ int fxStringEndsWith(const char *string, const char *suffix) /* $262 */ +void fx_agent_get_safeBroadcast(xsMachine* the) +{ + xsResult = xsGet(xsThis, xsID("broadcast")); +} + +void fx_agent_set_safeBroadcast(xsMachine* the) +{ +} + void fx_agent_broadcast(xsMachine* the) { if (xsIsInstanceOf(xsArg(0), xsTypedArrayPrototype)) { @@ -1117,11 +1131,6 @@ void fx_createRealm(xsMachine* the) xsResult = xsThis; } -void fx_createRealmException(xsMachine* the) -{ - mxUnknownError("one realm only"); -} - void fx_detachArrayBuffer(xsMachine* the) { txSlot* slot = mxArgv(0);