File tree Expand file tree Collapse file tree 1 file changed +29
-27
lines changed
Expand file tree Collapse file tree 1 file changed +29
-27
lines changed Original file line number Diff line number Diff line change 1111doAssert a.toJson () == """ 123 """
1212doAssert b.toJson () == """ null """
1313
14- doAssert $ (fromJson (""" 1 """ , ref int )[]) == " 1"
15- doAssert fromJson (""" null """ , ref int ) == nil
16-
17- proc check [T](v: T) =
18- var v2: ref T = newRef (v)
19- var v3: ref T = nil
20- doAssert v2.toJson.fromJson (ref T)[] == v2[]
21- doAssert v3.toJson.fromJson (ref T) == nil
22-
23- check (1 .int )
24- check (1 .int8 )
25- check (1 .int16 )
26- check (1 .int32 )
27- check (1 .int64 )
28- check (1 .uint8 )
29- check (1 .uint16 )
30- check (1 .uint32 )
31- check (1 .uint64 )
32-
33- check (" hello" )
34- check ([1 , 2 , 3 ])
35- check (@ [1 , 2 , 3 ])
36-
37- type Entry = object
38- color: string
39-
40- check (Entry ())
14+ when not defined (js):
15+ # JS has a bug with ref ints: https://github.com/nim-lang/Nim/issues/21317
16+ doAssert $ (fromJson (""" 1 """ , ref int )[]) == " 1"
17+ doAssert fromJson (""" null """ , ref int ) == nil
18+
19+ proc check [T](v: T) =
20+ var v2: ref T = newRef (v)
21+ var v3: ref T = nil
22+ doAssert v2.toJson.fromJson (ref T)[] == v2[]
23+ doAssert v3.toJson.fromJson (ref T) == nil
24+
25+ check (1 .int )
26+ check (1 .int8 )
27+ check (1 .int16 )
28+ check (1 .int32 )
29+ check (1 .int64 )
30+ check (1 .uint8 )
31+ check (1 .uint16 )
32+ check (1 .uint32 )
33+ check (1 .uint64 )
34+
35+ check (" hello" )
36+ check ([1 , 2 , 3 ])
37+ check (@ [1 , 2 , 3 ])
38+
39+ type Entry = object
40+ color: string
41+
42+ check (Entry ())
4143
4244type
4345 Test = object
You can’t perform that action at this time.
0 commit comments