json-as 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.prettierignore +6 -0
  2. package/.prettierrc.json +0 -1
  3. package/CHANGELOG +9 -1
  4. package/README.md +3 -3
  5. package/as-test.config.json +1 -1
  6. package/asconfig.json +1 -29
  7. package/assembly/__tests__/array.spec.ts +67 -0
  8. package/assembly/__tests__/bool.spec.ts +4 -12
  9. package/assembly/__tests__/float.spec.ts +11 -21
  10. package/assembly/__tests__/integer.spec.ts +7 -9
  11. package/assembly/__tests__/null.spec.ts +12 -0
  12. package/assembly/__tests__/obj.spec.ts +137 -3
  13. package/assembly/__tests__/simd/string.spec.ts +21 -21
  14. package/assembly/__tests__/string.spec.ts +6 -4
  15. package/assembly/__tests__/test.spec.ts +120 -191
  16. package/assembly/deserialize/simple/bool.ts +1 -1
  17. package/assembly/deserialize/simple/map.ts +1 -1
  18. package/assembly/deserialize/simple/string.ts +4 -3
  19. package/assembly/globals/tables.ts +74 -416
  20. package/assembly/index.ts +18 -18
  21. package/assembly/serialize/simd/string.ts +10 -10
  22. package/assembly/serialize/simple/array.ts +4 -4
  23. package/assembly/serialize/simple/bool.ts +2 -2
  24. package/assembly/serialize/simple/date.ts +1 -1
  25. package/assembly/serialize/simple/float.ts +1 -1
  26. package/assembly/serialize/simple/integer.ts +1 -1
  27. package/assembly/serialize/simple/map.ts +6 -6
  28. package/assembly/serialize/simple/string.ts +3 -3
  29. package/assembly/test.ts +4 -43
  30. package/assembly/util/bytes.ts +1 -1
  31. package/modules/as-bs/assembly/index.ts +33 -83
  32. package/modules/test/assembly/index.ts +22 -0
  33. package/package.json +3 -7
  34. package/run-tests.sh +15 -0
  35. package/transform/lib/index.js +1 -1
  36. package/transform/lib/index.js.map +1 -1
  37. package/transform/src/index.ts +1 -1
@@ -0,0 +1,6 @@
1
+ # Build artifacts
2
+ build/
3
+ transform/lib
4
+
5
+ # Tables
6
+ assembly/globals/tables.ts
package/.prettierrc.json CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
- "pluginSearchDirs": ["node_modules"],
3
2
  "plugins": ["assemblyscript-prettier"],
4
3
  "singleQuote": false,
5
4
  "printWidth": 65536,
package/CHANGELOG CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## UNRELEASED
3
+ ## 2025-01-31 - 1.0.0-alpha.3
4
+
5
+ - fix: write to proper offset when deserializing string with \u0000-type escapes
6
+ - fix: simplify and fix memory offset issues with bs module
7
+ - fix: properly predict minimum size of to-be-serialized schemas
8
+ - fix: replace as-test with temporary framework to mitigate json-as versioning issues
9
+ - fix: fix multiple memory leaks during serialization
10
+ - feat: align memory allocations for better performance
11
+ - feat: achieve a space complexity of O(n) for serialization operations, unless dealing with \u0000-type escapes
4
12
 
5
13
  ## 2025-01-20 - 1.0.0-alpha.2
6
14
 
package/README.md CHANGED
@@ -6,14 +6,14 @@
6
6
  ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
7
7
  █████ ███████ ██████ ██ ████ ██ ██ ███████
8
8
  </span>
9
- AssemblyScript - v1.0.0-alpha.2
9
+ AssemblyScript - v1.0.0-alpha.3
10
10
  </pre>
11
11
  </h5>
12
12
 
13
13
  ## Installation
14
14
 
15
15
  ```bash
16
- npm install json-as@1.0.0-alpha.2
16
+ npm install json-as@1.0.0-alpha.3
17
17
  ```
18
18
 
19
19
  Add the `--transform` to your `asc` command (e.g. in package.json)
@@ -28,7 +28,7 @@ Alternatively, add it to your `asconfig.json`
28
28
  {
29
29
  // ...
30
30
  "options": {
31
- "transform": ["json-as"]
31
+ "transform": ["json-as/transform"]
32
32
  }
33
33
  }
34
34
  ```
@@ -1,5 +1,5 @@
1
1
  {
2
- "input": ["./assembly/__tests__/*.spec.ts"],
2
+ "input": ["./assembly/__tests__/string.spec.ts"],
3
3
  "outDir": "./build",
4
4
  "config": "none",
5
5
  "plugins": {
package/asconfig.json CHANGED
@@ -1,33 +1,5 @@
1
1
  {
2
- "targets": {
3
- "test": {
4
- "outFile": "build/test.spec.wasm",
5
- "textFile": "build/test.spec.wat",
6
- "sourceMap": true,
7
- "optimizeLevel": 0,
8
- "shrinkLevel": 0,
9
- "converge": false,
10
- "noAssert": false
11
- },
12
- "debug": {
13
- "outFile": "build/test.wasm",
14
- "textFile": "build/test.wat",
15
- "sourceMap": true,
16
- "optimizeLevel": 0,
17
- "shrinkLevel": 0,
18
- "converge": false,
19
- "noAssert": false
20
- },
21
- "bench": {
22
- "outFile": "build/bench.wasm",
23
- "textFile": "build/bench.wat",
24
- "sourceMap": true,
25
- "optimizeLevel": 3,
26
- "shrinkLevel": 0,
27
- "converge": true,
28
- "noAssert": true
29
- }
30
- },
2
+ "targets": {},
31
3
  "options": {
32
4
  "transform": [],
33
5
  "disableWarning": []
@@ -0,0 +1,67 @@
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
+
4
+ describe("Should serialize integer arrays", () => {
5
+ expect(JSON.stringify<u32[]>([0, 100, 101])).toBe("[0,100,101]");
6
+
7
+ expect(JSON.stringify<u64[]>([0, 100, 101])).toBe("[0,100,101]");
8
+
9
+ expect(JSON.stringify<i32[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
10
+
11
+ expect(JSON.stringify<i64[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
12
+ });
13
+
14
+ describe("Should serialize float arrays", () => {
15
+ expect(JSON.stringify<f64[]>([7.23, 10e2, 10e2, 123456e-5, 123456e-5, 0.0, 7.23])).toBe("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]");
16
+
17
+ expect(JSON.stringify<f64[]>([1e21, 1e22, 1e-7, 1e-8, 1e-9])).toBe("[1e+21,1e+22,1e-7,1e-8,1e-9]");
18
+ });
19
+
20
+ describe("Should serialize boolean arrays", () => {
21
+ expect(JSON.stringify<bool[]>([true, false])).toBe("[true,false]");
22
+
23
+ expect(JSON.stringify<boolean[]>([true, false])).toBe("[true,false]");
24
+ });
25
+
26
+ describe("Should serialize string arrays", () => {
27
+ expect(JSON.stringify<string[]>(['string "with random spa\nces and \nnewlines\n\n\n'])).toBe('["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]');
28
+ });
29
+
30
+ describe("Should serialize nested integer arrays", () => {
31
+ expect(JSON.stringify<i64[][]>([[100, 101], [-100, -101], [0]])).toBe("[[100,101],[-100,-101],[0]]");
32
+ });
33
+
34
+ describe("Should serialize nested float arrays", () => {
35
+ expect(JSON.stringify<f64[][]>([[7.23], [10e2], [10e2], [123456e-5], [123456e-5], [0.0], [7.23]])).toBe("[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]");
36
+ });
37
+
38
+ describe("Should serialize nested boolean arrays", () => {
39
+ expect(JSON.stringify<bool[][]>([[true], [false]])).toBe("[[true],[false]]");
40
+
41
+ expect(JSON.stringify<boolean[][]>([[true], [false]])).toBe("[[true],[false]]");
42
+ });
43
+
44
+ describe("Should serialize object arrays", () => {
45
+ expect(
46
+ JSON.stringify<Vec3[]>([
47
+ {
48
+ x: 3.4,
49
+ y: 1.2,
50
+ z: 8.3,
51
+ },
52
+ {
53
+ x: 3.4,
54
+ y: -2.1,
55
+ z: 9.3,
56
+ },
57
+ ]),
58
+ ).toBe('[{"x":3.4,"y":1.2,"z":8.3},{"x":3.4,"y":-2.1,"z":9.3}]');
59
+ });
60
+
61
+
62
+ @json
63
+ class Vec3 {
64
+ x: f64 = 0.0;
65
+ y: f64 = 0.0;
66
+ z: f64 = 0.0;
67
+ }
@@ -1,20 +1,12 @@
1
- import { JSON } from "../";
2
- import { describe, expect, run } from "as-test/assembly";
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
3
 
4
4
  describe("Should serialize booleans", () => {
5
5
  expect(JSON.stringify<bool>(true)).toBe("true");
6
-
7
6
  expect(JSON.stringify<bool>(false)).toBe("false");
8
-
9
- expect(JSON.stringify<boolean>(true)).toBe("true");
10
-
11
- expect(JSON.stringify<boolean>(false)).toBe("false");
12
7
  });
13
8
 
14
9
  describe("Should deserialize booleans", () => {
15
- expect(JSON.parse<boolean>("true")).toBe(true);
16
-
17
- expect(JSON.parse<boolean>("false")).toBe(false);
10
+ expect(JSON.parse<boolean>("true").toString()).toBe("true");
11
+ expect(JSON.parse<boolean>("false").toString()).toBe("false");
18
12
  });
19
-
20
- run();
@@ -1,5 +1,5 @@
1
- import { JSON } from "json-as";
2
- import { describe, expect, run } from "as-test/assembly";
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
3
 
4
4
  describe("Should serialize floats", () => {
5
5
  expect(JSON.stringify<f64>(7.23)).toBe("7.23");
@@ -16,37 +16,27 @@ describe("Should serialize floats", () => {
16
16
 
17
17
  expect(JSON.stringify<f64>(1e-7)).toBe("1e-7");
18
18
 
19
- expect(JSON.parse<f64>("1E-7")).toBe(1e-7);
20
-
21
19
  expect(JSON.stringify<f64>(1e20)).toBe("100000000000000000000.0");
22
20
 
23
21
  expect(JSON.stringify<f64>(1e21)).toBe("1e+21");
24
-
25
- expect(JSON.parse<f64>("1E+21")).toBe(1e21);
26
-
27
- expect(JSON.parse<f64>("1e21")).toBe(1e21);
28
-
29
- expect(JSON.parse<f64>("1E21")).toBe(1e21);
30
22
  });
31
23
 
32
24
  describe("Should deserialize floats", () => {
33
- expect(JSON.parse<f64>("7.23")).toBe(7.23);
25
+ expect(JSON.parse<f64>("7.23").toString()).toBe("7.23");
34
26
 
35
- expect(JSON.parse<f64>("1000.0")).toBe(1000.0);
27
+ expect(JSON.parse<f64>("1000.0").toString()).toBe("1000.0");
36
28
 
37
- expect(JSON.parse<f64>("1.23456")).toBe(1.23456);
29
+ expect(JSON.parse<f64>("1.23456").toString()).toBe("1.23456");
38
30
 
39
- expect(JSON.parse<f64>("0.0")).toBe(0.0);
31
+ expect(JSON.parse<f64>("0.0").toString()).toBe("0.0");
40
32
 
41
- expect(JSON.parse<f64>("-7.23")).toBe(-7.23);
33
+ expect(JSON.parse<f64>("-7.23").toString()).toBe("-7.23");
42
34
 
43
- expect(JSON.parse<f64>("0.000001")).toBe(0.000001);
35
+ expect(JSON.parse<f64>("0.000001").toString()).toBe("0.000001");
44
36
 
45
- expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
37
+ // expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
46
38
 
47
- expect(JSON.parse<f64>("100000000000000000000.0")).toBe(1e20);
39
+ // expect(JSON.parse<f64>("100000000000000000000.0").toString()).toBe(1e20);
48
40
 
49
- expect(JSON.parse<f64>("1e+21")).toBe(1e21);
41
+ // expect(JSON.parse<f64>("1e+21")).toBe(1e21);
50
42
  });
51
-
52
- run();
@@ -1,5 +1,5 @@
1
- import { JSON } from "json-as";
2
- import { describe, expect, run } from "as-test/assembly";
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
3
 
4
4
  describe("Should serialize integers", () => {
5
5
  expect(JSON.stringify(0)).toBe("0");
@@ -14,15 +14,13 @@ describe("Should serialize integers", () => {
14
14
  });
15
15
 
16
16
  describe("Should deserialize integers", () => {
17
- expect(JSON.parse<i32>("0")).toBe(<i32>0);
17
+ expect(JSON.parse<i32>("0").toString()).toBe("0");
18
18
 
19
- expect(JSON.parse<u32>("100")).toBe(<u32>100);
19
+ expect(JSON.parse<u32>("100").toString()).toBe("100");
20
20
 
21
- expect(JSON.parse<u64>("101")).toBe(<u64>101);
21
+ expect(JSON.parse<u64>("101").toString()).toBe("101");
22
22
 
23
- expect(JSON.parse<i32>("-100")).toBe(<i32>-100);
23
+ expect(JSON.parse<i32>("-100").toString()).toBe("-100");
24
24
 
25
- expect(JSON.parse<i64>("-101")).toBe(<i64>-101);
25
+ expect(JSON.parse<i64>("-101").toString()).toBe("-101");
26
26
  });
27
-
28
- run();
@@ -0,0 +1,12 @@
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
+
4
+ describe("Should serialize null", () => {
5
+ expect(JSON.stringify(null)).toBe("null");
6
+ });
7
+
8
+ describe("Should serialize nullable classes", () => {
9
+ expect(JSON.stringify<Nullable | null>(null)).toBe("null");
10
+ });
11
+
12
+ class Nullable {}
@@ -1,4 +1,138 @@
1
- import { JSON } from "json-as";
2
- import { describe, expect, run } from "as-test/assembly";
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
3
 
4
- run();
4
+ describe("Should serialize objects", () => {
5
+ expect(
6
+ JSON.stringify<Vec3>({
7
+ x: 3.4,
8
+ y: 1.2,
9
+ z: 8.3,
10
+ }),
11
+ ).toBe('{"x":3.4,"y":1.2,"z":8.3}');
12
+
13
+ expect(
14
+ JSON.stringify<Player>({
15
+ firstName: "Emmet",
16
+ lastName: "West",
17
+ lastActive: [8, 27, 2022],
18
+ age: 23,
19
+ pos: {
20
+ x: 3.4,
21
+ y: 1.2,
22
+ z: 8.3,
23
+ },
24
+ isVerified: true,
25
+ }),
26
+ ).toBe('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}');
27
+
28
+ expect(JSON.stringify<ObjectWithFloat>({ f: 7.23 })).toBe('{"f":7.23}');
29
+
30
+ expect(JSON.stringify<ObjectWithFloat>({ f: 0.000001 })).toBe('{"f":0.000001}');
31
+
32
+ expect(JSON.stringify<ObjectWithFloat>({ f: 1e-7 })).toBe('{"f":1e-7}');
33
+
34
+ expect(JSON.stringify<ObjectWithFloat>({ f: 1e20 })).toBe('{"f":100000000000000000000.0}');
35
+
36
+ expect(JSON.stringify<ObjectWithFloat>({ f: 1e21 })).toBe('{"f":1e+21}');
37
+
38
+ expect(JSON.stringify<ObjWithStrangeKey<string>>({ data: "foo" })).toBe('{"a\\\\\\t\\"\\u0002b`c":"foo"}');
39
+ });
40
+
41
+ describe("Should serialize objects with inheritance", () => {
42
+ const obj = new DerivedObject("1", "2");
43
+
44
+ expect(JSON.stringify(obj)).toBe('{"a":"1","b":"2"}');
45
+ });
46
+
47
+ describe("Should ignore properties decorated with @omit", () => {
48
+ expect(
49
+ JSON.stringify(<OmitIf>{
50
+ y: 1,
51
+ }),
52
+ ).toBe('{"y":1,"x":1,"z":1}');
53
+ });
54
+
55
+
56
+ @json
57
+ class BaseObject {
58
+ a: string;
59
+ constructor(a: string) {
60
+ this.a = a;
61
+ }
62
+ }
63
+
64
+
65
+ @json
66
+ class DerivedObject extends BaseObject {
67
+ b: string;
68
+ constructor(a: string, b: string) {
69
+ super(a);
70
+ this.b = b;
71
+ }
72
+ }
73
+
74
+
75
+ @json
76
+ class Vec3 {
77
+ x: f64 = 0.0;
78
+ y: f64 = 0.0;
79
+ z: f64 = 0.0;
80
+ }
81
+
82
+
83
+ @json
84
+ class Player {
85
+ firstName!: string;
86
+ lastName!: string;
87
+ lastActive!: i32[];
88
+ age!: i32;
89
+ pos!: Vec3 | null;
90
+ isVerified!: boolean;
91
+ }
92
+
93
+
94
+ @json
95
+ class ObjWithString {
96
+ s!: string;
97
+ }
98
+
99
+
100
+ @json
101
+ class ObjWithStrangeKey<T> {
102
+
103
+ @alias('a\\\t"\x02b`c')
104
+ data!: T;
105
+ }
106
+
107
+
108
+ @json
109
+ class ObjectWithStringArray {
110
+ sa!: string[];
111
+ }
112
+
113
+
114
+ @json
115
+ class ObjectWithFloat {
116
+ f!: f64;
117
+ }
118
+
119
+
120
+ @json
121
+ class ObjectWithFloatArray {
122
+ fa!: f64[];
123
+ }
124
+
125
+
126
+ @json
127
+ class OmitIf {
128
+ x: i32 = 1;
129
+
130
+
131
+ @omitif("this.y == -1")
132
+ y: i32 = -1;
133
+ z: i32 = 1;
134
+
135
+
136
+ @omitnull()
137
+ foo: string | null = null;
138
+ }
@@ -1,32 +1,32 @@
1
- import { describe, expect, run } from "as-test/assembly";
2
- import { serializeString_SIMD } from "../../serialize/simd/string";
3
- import { deserializeString_SIMD } from "../../deserialize/simd/string";
1
+ // import { describe, expect, run } from "as-test/assembly";
2
+ // import { serializeString_SIMD } from "../../serialize/simd/string";
3
+ // import { deserializeString_SIMD } from "../../deserialize/simd/string";
4
4
 
5
- const out = changetype<usize>(new ArrayBuffer(512));
5
+ // const out = changetype<usize>(new ArrayBuffer(512));
6
6
 
7
- const serialize_simd = (data: string): string => String.UTF16.decodeUnsafe(out, serializeString_SIMD(data, out));
8
- const deserialize_simd = (data: string): string => String.UTF16.decodeUnsafe(out, deserializeString_SIMD(data, out));
9
- describe("Should serialize strings", () => {
10
- expect(serialize_simd("abcdefg")).toBe('"abcdefg"');
7
+ // const serialize_simd = (data: string): string => String.UTF16.decodeUnsafe(out, serializeString_SIMD(data, out));
8
+ // const deserialize_simd = (data: string): string => String.UTF16.decodeUnsafe(out, deserializeString_SIMD(data, out));
9
+ // describe("Should serialize strings", () => {
10
+ // expect(serialize_simd("abcdefg")).toBe('"abcdefg"');
11
11
 
12
- expect(serialize_simd('st"ring" w""ith quotes"')).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
12
+ // expect(serialize_simd('st"ring" w""ith quotes"')).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
13
13
 
14
- expect(serialize_simd('string "with random spa\nces and \nnewlines\n\n\n')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
14
+ // expect(serialize_simd('string "with random spa\nces and \nnewlines\n\n\n')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
15
15
 
16
- expect(serialize_simd('string with colon : comma , brace [ ] bracket { } and quote " and other quote "')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""');
16
+ // expect(serialize_simd('string with colon : comma , brace [ ] bracket { } and quote " and other quote "')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""');
17
17
 
18
- expect(serialize_simd("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f")).toBe('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"');
19
- });
18
+ // expect(serialize_simd("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f")).toBe('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"');
19
+ // });
20
20
 
21
- describe("Should deserialize strings", () => {
22
- expect(deserialize_simd('"abcdefg"')).toBe("abcdefg");
23
- expect(deserialize_simd('"st\\"ring\\" w\\"\\"ith quotes\\""')).toBe('st"ring" w""ith quotes"');
21
+ // describe("Should deserialize strings", () => {
22
+ // expect(deserialize_simd('"abcdefg"')).toBe("abcdefg");
23
+ // expect(deserialize_simd('"st\\"ring\\" w\\"\\"ith quotes\\""')).toBe('st"ring" w""ith quotes"');
24
24
 
25
- expect(deserialize_simd('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"')).toBe('string "with random spa\nces and \nnewlines\n\n\n');
25
+ // expect(deserialize_simd('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"')).toBe('string "with random spa\nces and \nnewlines\n\n\n');
26
26
 
27
- expect(deserialize_simd('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""')).toBe('string with colon : comma , brace [ ] bracket { } and quote " and other quote "');
27
+ // expect(deserialize_simd('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""')).toBe('string with colon : comma , brace [ ] bracket { } and quote " and other quote "');
28
28
 
29
- expect(deserialize_simd('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"')).toBe("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f");
30
- });
29
+ // expect(deserialize_simd('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"')).toBe("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f");
30
+ // });
31
31
 
32
- run();
32
+ // run();
@@ -1,5 +1,5 @@
1
- import { JSON } from "json-as";
2
- import { describe, expect, run } from "as-test/assembly";
1
+ import { JSON } from "..";
2
+ import { describe, expect } from "../../modules/test/assembly";
3
3
 
4
4
  describe("Should serialize strings", () => {
5
5
  expect(JSON.stringify("abcdefg")).toBe('"abcdefg"');
@@ -9,6 +9,8 @@ describe("Should serialize strings", () => {
9
9
  expect(JSON.stringify('string "with random spa\nces and \nnewlines\n\n\n')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
10
10
 
11
11
  expect(JSON.stringify('string with colon : comma , brace [ ] bracket { } and quote " and other quote \\"')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\\\""');
12
+
13
+ expect(JSON.stringify("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f")).toBe('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"');
12
14
  });
13
15
 
14
16
  describe("Should deserialize strings", () => {
@@ -19,6 +21,6 @@ describe("Should deserialize strings", () => {
19
21
  expect(JSON.parse<string>('"\\"string \\\\\\"with random spa\\\\nces and \\\\nnewlines\\\\n\\\\n\\\\n\\""')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
20
22
 
21
23
  expect(JSON.parse<string>('"\\"string with colon : comma , brace [ ] bracket { } and quote \\\\\\" and other quote \\\\\\\\\\"\\""')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\""');
22
- });
23
24
 
24
- run();
25
+ expect(JSON.parse<string>('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"')).toBe("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f\u000f\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f");
26
+ });