Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | // this are dev dependencies
|
---|
2 | var diff = require("jest-diff");
|
---|
3 |
|
---|
4 | var _require = require("jest-diff/build/constants"),
|
---|
5 | NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE;
|
---|
6 |
|
---|
7 | var _require2 = require("@webassemblyjs/wasm-parser"),
|
---|
8 | decode = _require2.decode;
|
---|
9 |
|
---|
10 | var oldConsoleLog = console.log;
|
---|
11 | export function compareArrayBuffers(l, r) {
|
---|
12 | /**
|
---|
13 | * Decode left
|
---|
14 | */
|
---|
15 | var bufferL = "";
|
---|
16 |
|
---|
17 | console.log = function () {
|
---|
18 | for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) {
|
---|
19 | texts[_key] = arguments[_key];
|
---|
20 | }
|
---|
21 |
|
---|
22 | return bufferL += texts.join("") + "\n";
|
---|
23 | };
|
---|
24 |
|
---|
25 | try {
|
---|
26 | decode(l, {
|
---|
27 | dump: true
|
---|
28 | });
|
---|
29 | } catch (e) {
|
---|
30 | console.error(bufferL);
|
---|
31 | console.error(e);
|
---|
32 | throw e;
|
---|
33 | }
|
---|
34 | /**
|
---|
35 | * Decode right
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | var bufferR = "";
|
---|
40 |
|
---|
41 | console.log = function () {
|
---|
42 | for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
---|
43 | texts[_key2] = arguments[_key2];
|
---|
44 | }
|
---|
45 |
|
---|
46 | return bufferR += texts.join("") + "\n";
|
---|
47 | };
|
---|
48 |
|
---|
49 | try {
|
---|
50 | decode(r, {
|
---|
51 | dump: true
|
---|
52 | });
|
---|
53 | } catch (e) {
|
---|
54 | console.error(bufferR);
|
---|
55 | console.error(e);
|
---|
56 | throw e;
|
---|
57 | }
|
---|
58 |
|
---|
59 | console.log = oldConsoleLog;
|
---|
60 | var out = diff(bufferL, bufferR);
|
---|
61 |
|
---|
62 | if (out !== null && out !== NO_DIFF_MESSAGE) {
|
---|
63 | throw new Error("\n" + out);
|
---|
64 | }
|
---|
65 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.