tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

br-null.js (1017B)


      1 // br_on_null from constant
      2 wasmValidateText(`(module
      3  (func
      4    ref.null extern
      5    br_on_null 0
      6    drop
      7  )
      8 )`);
      9 
     10 // br_on_null from parameter
     11 wasmValidateText(`(module
     12  (func (param externref)
     13    local.get 0
     14    br_on_null 0
     15    drop
     16  )
     17 )`);
     18 
     19 // br_on_null with single result
     20 wasmValidateText(`(module
     21  (func (result i32)
     22    i32.const 0
     23    ref.null extern
     24    br_on_null 0
     25    drop
     26  )
     27 )`);
     28 
     29 // br_on_null with multiple results
     30 wasmValidateText(`(module
     31  (func (result i32 i32 i32)
     32    i32.const 0
     33    i32.const 1
     34    i32.const 2
     35    ref.null extern
     36    br_on_null 0
     37    drop
     38  )
     39 )`);
     40 
     41 // Test the branch takes the correct path and results are passed correctly
     42 let {isNull} = wasmEvalText(`(module
     43  (func (export "isNull") (param externref) (result i32)
     44    i32.const 1
     45    local.get 0
     46    br_on_null 0
     47    drop
     48    drop
     49    i32.const 0
     50  )
     51 )`).exports;
     52 
     53 assertEq(isNull(null), 1, `null is null`);
     54 for (let val of WasmNonNullExternrefValues) {
     55  assertEq(isNull(val), 0, `${typeof(val)} is not null`);
     56 }