@@ -52,6 +52,15 @@ const EXPECT_INVALID = false;
5252
5353/* DATA **********************************************************************/
5454
55+ let hostrefs = { } ;
56+ let hostsym = Symbol ( "hostref" ) ;
57+ function hostref ( s ) {
58+ if ( ! ( s in hostrefs ) ) hostrefs [ s ] = { [ hostsym ] : s } ;
59+ return hostrefs [ s ] ;
60+ }
61+ function eq_ref ( x , y ) {
62+ return x === y ? 1 : 0 ;
63+ }
5564let externrefs = { } ;
5665let externsym = Symbol ( "externref" ) ;
5766function externref ( s ) {
@@ -86,6 +95,8 @@ function reinitializeRegistry() {
8695
8796 chain = chain . then ( _ => {
8897 let spectest = {
98+ hostref : hostref ,
99+ eq_ref : eq_ref ,
89100 externref : externref ,
90101 is_externref : is_externref ,
91102 is_funcref : is_funcref ,
@@ -182,22 +193,22 @@ function assert_invalid_custom(bytes) {
182193
183194const assert_malformed_custom = assert_invalid_custom ;
184195
185- function instance ( bytes , imports , valid = true ) {
196+ function instance ( module , imports , valid = true ) {
186197 const test = valid
187198 ? "Test that WebAssembly instantiation succeeds"
188199 : "Test that WebAssembly instantiation fails" ;
189200 const loc = new Error ( ) . stack . toString ( ) . replace ( "Error" , "" ) ;
190- chain = Promise . all ( [ imports , chain ] )
201+ chain = Promise . all ( [ module , imports , chain ] )
191202 . then ( values => {
192- let imports = values [ 0 ] ? values [ 0 ] : registry ;
193- return WebAssembly . instantiate ( binary ( bytes ) , imports ) ;
203+ let imports = values [ 1 ] ? values [ 1 ] : registry ;
204+ return WebAssembly . instantiate ( values [ 0 ] , imports ) ;
194205 } )
195206 . then (
196- pair => {
207+ inst => {
197208 uniqueTest ( _ => {
198209 assert_true ( valid , loc ) ;
199210 } , test ) ;
200- return pair . instance ;
211+ return inst ;
201212 } ,
202213 error => {
203214 uniqueTest ( _ => {
0 commit comments