File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,14 @@ const jsc = globalThis["\x24"];
3
3
const DollarCreateRealm = jsc . createRealm ;
4
4
const DollarEvalScript = jsc . evalScript . bind ( jsc ) ;
5
5
6
- var $262 = Object . assign ( { } , jsc ) ;
6
+ var $262 = { } ;
7
+ // Copy "own" properties from the JSC-defined object to the normalized `$262`
8
+ // object. Neither `Object.assign` nor the object "spread" syntax can be used
9
+ // for this task because not all properties on the source object are
10
+ // enumerable.
11
+ Object . getOwnPropertyNames ( jsc ) . forEach ( function ( name ) {
12
+ $262 [ name ] = jsc [ name ] ;
13
+ } ) ;
7
14
$262 . global = globalThis ;
8
15
$262 . source = $SOURCE ;
9
16
$262 . destroy = function ( ) { } ;
Original file line number Diff line number Diff line change @@ -958,5 +958,26 @@ hosts.forEach(function (record) {
958
958
await agent . destroy ( ) ;
959
959
} ) ;
960
960
} ) ;
961
+
962
+ describe ( "agent" , ( ) => {
963
+ if ( ! [ "jsc" , "jsshell" , "d8" ] . includes ( type ) ) {
964
+ return ;
965
+ }
966
+
967
+ const read = async ( expression ) => {
968
+ const result = await agent . evalScript ( `print(${ expression } );` ) ;
969
+ expect ( result . error ) . toBe ( null ) ;
970
+ return result . stdout ;
971
+ } ;
972
+
973
+ it ( "exposes the complete Test262-defined API" , async ( ) => {
974
+ expect ( await read ( "typeof $262.agent" ) ) . toMatch ( / ^ o b j e c t / ) ;
975
+ expect ( await read ( "typeof $262.agent.start" ) ) . toMatch ( / ^ f u n c t i o n / ) ;
976
+ expect ( await read ( "typeof $262.agent.broadcast" ) ) . toMatch ( / ^ f u n c t i o n / ) ;
977
+ expect ( await read ( "typeof $262.agent.getReport" ) ) . toMatch ( / ^ f u n c t i o n / ) ;
978
+ expect ( await read ( "typeof $262.agent.sleep" ) ) . toMatch ( / ^ f u n c t i o n / ) ;
979
+ expect ( await read ( "typeof $262.agent.monotonicNow" ) ) . toMatch ( / ^ f u n c t i o n / ) ;
980
+ } ) ;
981
+ } ) ;
961
982
} ) ;
962
983
} ) ;
You can’t perform that action at this time.
0 commit comments