summaryrefslogtreecommitdiff
path: root/test/lit/passes/string-lowering.js
blob: 105970bccc3f4545b7443cd7028d7ef6c550d694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var filename = process.argv[2];
var module = new WebAssembly.Module(require('fs').readFileSync(filename));
var sections = WebAssembly.Module.customSections(module, 'string.consts');
var array = new Uint8Array(sections[0]);
var string = new TextDecoder('utf-8').decode(array);

function standardizeEncoding(s) {
  // Different node.js versions print differently, so we must standardize to
  // pass tests in all places. In particular at some point node.js started to
  // abbreviate \u0000 as \x00 (both of which are valid).
  return s.replace('\\u0000', '\\x00');
}

console.log("string:", standardizeEncoding(string));

var json = JSON.stringify(JSON.parse(string));
console.log("JSON:", standardizeEncoding(json));