Skip to content

Commit a663593

Browse files
committed
lint and tests
1 parent b85075f commit a663593

5 files changed

+106
-11
lines changed

src/support/json.h

+12-11
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,18 @@ struct Value {
257257
while (*curr && is_json_space(*curr)) \
258258
curr++; \
259259
}
260-
#define skip_escaped_characters(ptr)\
261-
while (*ptr && *ptr != '"') {\
262-
if (*ptr == '\\' && *(ptr + 1)) {\
263-
ptr++;\
264-
}\
265-
ptr++;\
266-
}
267-
#define RUNTIME_ASSERT(condition)\
268-
if (!(condition)) {\
269-
std::cerr << "Assertion failed: " #condition << " at " << __FILE__ << ":" << __LINE__ << "\n";\
270-
std::terminate();\
260+
#define skip_escaped_characters(ptr) \
261+
while (*ptr && *ptr != '"') { \
262+
if (*ptr == '\\' && *(ptr + 1)) { \
263+
ptr++; \
264+
} \
265+
ptr++; \
266+
}
267+
#define RUNTIME_ASSERT(condition) \
268+
if (!(condition)) { \
269+
std::cerr << "Assertion failed: " #condition << " at " << __FILE__ << ":" \
270+
<< __LINE__ << "\n"; \
271+
std::terminate(); \
271272
}
272273
skip();
273274
if (*curr == '"') {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
;; RUN: wasm-metadce %s --graph-file %s.json -S -o - | filecheck %s --check-prefix=TXT
3+
;; RUN: wasm-as %s -o %t.wasm --source-map %t.map
4+
;; RUN: wasm-metadce %t.wasm --input-source-map %t.map --graph-file %s.json -o %t.out.wasm --output-source-map %t.out.map
5+
;; RUN: wasm-dis %t.out.wasm --source-map %t.out.map -o - | filecheck %s --check-prefix=BIN
6+
7+
;; Test that sourcemap information is preserved
8+
9+
(module
10+
;;@ a:1:2
11+
;; TXT: (type $0 (func))
12+
13+
;; TXT: (export "f~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./" (func $f))
14+
15+
;; TXT: (func $f
16+
;; TXT-NEXT: ;;@ a:7:8:someSymbol
17+
;; TXT-NEXT: (nop)
18+
;; TXT-NEXT: ;;@ a:9:10
19+
;; TXT-NEXT: )
20+
(func $f (export "f~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./")
21+
;;@ a:7:8:someSymbol
22+
(nop)
23+
;;@ a:9:10
24+
)
25+
)
26+
;; BIN: (type $0 (func))
27+
28+
;; BIN: (export "f" (func $0))
29+
30+
;; BIN: (func $0
31+
;; BIN-NEXT: ;;@ a:7:8:someSymbol
32+
;; BIN-NEXT: (nop)
33+
;; BIN-NEXT: ;;@ a:9:10
34+
;; BIN-NEXT: )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"name": "root",
4+
"reaches": [
5+
"f~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./"
6+
],
7+
"root": true
8+
},
9+
{
10+
"name": "f~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./",
11+
"export": "f~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./"
12+
}
13+
]
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
;; RUN: wasm-metadce %s --graph-file %s.json -S -o - | filecheck %s --check-prefix=TXT
3+
;; RUN: wasm-as %s -o %t.wasm --source-map %t.map
4+
;; RUN: wasm-metadce %t.wasm --input-source-map %t.map --graph-file %s.json -o %t.out.wasm --output-source-map %t.out.map
5+
;; RUN: wasm-dis %t.out.wasm --source-map %t.out.map -o - | filecheck %s --check-prefix=BIN
6+
7+
;; Test that sourcemap information is preserved
8+
9+
(module
10+
;;@ a:1:2
11+
;; TXT: (type $0 (func))
12+
13+
;; TXT: (export "f" (func $f))
14+
15+
;; TXT: (func $f
16+
;; TXT-NEXT: ;;@ a:7:8:someSymbol
17+
;; TXT-NEXT: (nop)
18+
;; TXT-NEXT: ;;@ a:9:10
19+
;; TXT-NEXT: )
20+
(func $f (export "f")
21+
;;@ a:7:8:someSymbol
22+
(nop)
23+
;;@ a:9:10
24+
)
25+
)
26+
;; BIN: (type $0 (func))
27+
28+
;; BIN: (export "f" (func $0))
29+
30+
;; BIN: (func $0
31+
;; BIN-NEXT: ;;@ a:7:8:someSymbol
32+
;; BIN-NEXT: (nop)
33+
;; BIN-NEXT: ;;@ a:9:10
34+
;; BIN-NEXT: )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
name: "root",
4+
reaches: [
5+
"f"
6+
],
7+
root: true
8+
},
9+
{
10+
"name": "f",
11+
"export": "f"
12+
}
13+
]

0 commit comments

Comments
 (0)