• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattonem / PharoJS / 14220696386

11 Mar 2025 04:04PM UTC coverage: 42.026% (-17.4%) from 59.444%
14220696386

push

github

mattonem
more catching

1 of 1 new or added line in 1 file covered. (100.0%)

3707 existing lines in 69 files now uncovered.

8909 of 21199 relevant lines covered (42.03%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Pharo/PharoJs-Base-Serialization-Tests/PhxJavascriptJsonSerialisationTests.class.st
1
Class {
2
        #name : 'PhxJavascriptJsonSerialisationTests',
3
        #superclass : 'PjBridgeTestCase',
4
        #category : 'PharoJs-Base-Serialization-Tests',
5
        #package : 'PharoJs-Base-Serialization-Tests'
6
}
7

8
{ #category : 'tests' }
UNCOV
9
PhxJavascriptJsonSerialisationTests >> testArraysCircularReferences [
×
UNCOV
10
        | cClone aClone bClone |
×
UNCOV
11
        cClone := self evalBlock: [
×
UNCOV
12
                | a b c |
×
UNCOV
13
                a := {'A'. nil. nil. nil}.
×
UNCOV
14
                b := {'B'. nil. nil. nil }.
×
UNCOV
15
                c := {'C'. nil. nil. nil }.
×
UNCOV
16
                { a. b. c } do: [ : each |
×
UNCOV
17
                        each at: 2 put: a.
×
UNCOV
18
                        each at: 3 put: b.
×
UNCOV
19
                        each at: 4 put: c.
×
UNCOV
20
                ].
×
UNCOV
21
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
22
                ].        
×
UNCOV
23
        aClone := cClone second.
×
UNCOV
24
        bClone := cClone third.
×
UNCOV
25
        { aClone. bClone. cClone.}  with: #(A B C) do: [ : each : name |
×
UNCOV
26
                self assert: each size equals: 4.
×
UNCOV
27
                self assert: each first equals: name.
×
UNCOV
28
                self assert: each second identicalTo: aClone.
×
UNCOV
29
                self assert: each third identicalTo: bClone.
×
UNCOV
30
                self assert: each last identicalTo: cClone.
×
UNCOV
31
        ].
×
UNCOV
32
]
×
33

34
{ #category : 'tests' }
UNCOV
35
PhxJavascriptJsonSerialisationTests >> testDictionariesReferencingEachOther [
×
UNCOV
36
        <expectedFailure>
×
UNCOV
37
        | cClone aClone bClone |
×
UNCOV
38
        cClone := self evalBlock: [
×
UNCOV
39
                | a b c |
×
UNCOV
40
                a := Dictionary new.
×
UNCOV
41
                a at: #name put: 'A'.
×
UNCOV
42
                b := Dictionary new.
×
UNCOV
43
                b at: #name put: 'B'.
×
UNCOV
44
                b at: #a put: a.
×
UNCOV
45
                c := Dictionary new.
×
UNCOV
46
                c at: #name put: 'C'.
×
UNCOV
47
                c at: #a put: a.
×
UNCOV
48
                c at: #b put: b.
×
UNCOV
49
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
50
                ].
×
UNCOV
51
        self assert: cClone size equals: 3.
×
UNCOV
52
        aClone := cClone at: #a.
×
UNCOV
53
        self assert: aClone size equals: 1.
×
UNCOV
54
        self assert: (aClone at: #name) equals: 'A'.
×
UNCOV
55
        bClone := cClone at: #b.
×
UNCOV
56
        self assert: bClone size equals: 2.
×
UNCOV
57
        self assert: (bClone at: #name) equals: 'B'.
×
UNCOV
58
        self assert: (bClone at: #b) identicalTo: aClone.
×
UNCOV
59
]
×
60

61
{ #category : 'tests' }
UNCOV
62
PhxJavascriptJsonSerialisationTests >> testDictionariesWithCircularReferences [
×
UNCOV
63
        | cClone aClone bClone |
×
UNCOV
64
        cClone := self evalBlock: [
×
UNCOV
65
                | a b c |
×
UNCOV
66
                a := Dictionary new.
×
UNCOV
67
                a at: #name put: 'A'.
×
UNCOV
68
                b := Dictionary new.
×
UNCOV
69
                b at: #name put: 'B'.
×
UNCOV
70
                c := Dictionary new.
×
UNCOV
71
                c at: #name put: 'C'.
×
UNCOV
72
                { a. b. c } do: [ : each |
×
UNCOV
73
                        each at: #a put: a.
×
UNCOV
74
                        each at: #b put: b.
×
UNCOV
75
                        each at: #c put: c.
×
UNCOV
76
                ].
×
UNCOV
77
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
78
                ].
×
UNCOV
79
        aClone := cClone at: #a.
×
UNCOV
80
        bClone := cClone at: #b.
×
UNCOV
81
        { aClone. bClone. cClone.}  with: #(A B C) do: [ : each : name |
×
UNCOV
82
                self assert: each size equals: 4.
×
UNCOV
83
                self assert: (each at: #name) equals: name.
×
UNCOV
84
                self assert: (each at: #a) identicalTo: aClone.
×
UNCOV
85
                self assert: (each at: #b) identicalTo: bClone.
×
UNCOV
86
                self assert: (each at: #c) identicalTo: cClone.
×
UNCOV
87
        ].
×
UNCOV
88
]
×
89

90
{ #category : 'tests' }
UNCOV
91
PhxJavascriptJsonSerialisationTests >> testOrderedCollectionsCircularReferences [
×
UNCOV
92
        | cClone aClone bClone |
×
UNCOV
93
        cClone := self evalBlock: [
×
UNCOV
94
                | a b c |
×
UNCOV
95
                a := #('A') asOrderedCollection.
×
UNCOV
96
                b := {'B'} asOrderedCollection.
×
UNCOV
97
                c := {'C'} asOrderedCollection.
×
UNCOV
98
                { a. b. c } do: [ : each |
×
UNCOV
99
                        each add: a.
×
UNCOV
100
                        each add: b.
×
UNCOV
101
                        each add: c.
×
UNCOV
102
                ].
×
UNCOV
103
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
104
                ].        
×
UNCOV
105
        aClone := cClone second.
×
UNCOV
106
        bClone := cClone third.
×
UNCOV
107
        { aClone. bClone. cClone.}  with: #(A B C) do: [ : each : name |
×
UNCOV
108
                self assert: each size equals: 4.
×
UNCOV
109
                self assert: each first equals: name.
×
UNCOV
110
                self assert: each second identicalTo: aClone.
×
UNCOV
111
                self assert: each third identicalTo: bClone.
×
UNCOV
112
                self assert: each last identicalTo: cClone.
×
UNCOV
113
        ].
×
UNCOV
114
]
×
115

116
{ #category : 'tests' }
UNCOV
117
PhxJavascriptJsonSerialisationTests >> testSetsCircularReferences [
×
UNCOV
118
        <expectedFailure>
×
UNCOV
119
        | cClone aClone bClone identitySet |
×
UNCOV
120
        cClone := self evalBlock: [
×
UNCOV
121
                | a b c |
×
UNCOV
122
                a := {'A'} asSet.
×
UNCOV
123
                b := {'B'} asSet.
×
UNCOV
124
                c := {'C'} asSet.
×
UNCOV
125
                {a. b. c} do: [ : each | each addAll: {a. b. c} ].
×
UNCOV
126
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
127
                ].        
×
UNCOV
128
        aClone := cClone detect: [: each | each includes: 'A'] ifNone: [nil].
×
UNCOV
129
        bClone := cClone detect: [: each | each includes: 'B'] ifNone: [nil].
×
UNCOV
130
        { aClone. bClone. cClone.} with: #(A B C) do: [ : each : name |
×
UNCOV
131
                self assert: each size equals: 4.
×
UNCOV
132
                self assert: (each includes: name).
×
UNCOV
133
        ].
×
UNCOV
134
        identitySet := IdentitySet new.
×
UNCOV
135
        {aClone. bClone. cClone} do: [ : each | identitySet addAll: each ].
×
UNCOV
136
        identitySet removeAll: #(A B C).
×
UNCOV
137
        self assert: identitySet size equals: 3.
×
UNCOV
138
]
×
139

140
{ #category : 'tests' }
UNCOV
141
PhxJavascriptJsonSerialisationTests >> testSetsReferencingEachOther [
×
UNCOV
142
        | cClone bClone aInBClone aInCClone |
×
UNCOV
143
        cClone := self evalBlock: [
×
UNCOV
144
                | a b c |
×
UNCOV
145
                a := #('A') asSet.
×
UNCOV
146
                b := {'B'. a } asSet.
×
UNCOV
147
                c := {'C'. a. b } asSet.
×
UNCOV
148
                PhxJsonReader readFromString: c asPhxJsonString.
×
UNCOV
149
        ].
×
UNCOV
150
        self assert: cClone size equals: 3.
×
UNCOV
151
        self assert: (cClone includes: 'C').
×
UNCOV
152
        self deny: (cClone includes: cClone).
×
UNCOV
153
        bClone := cClone detect: [ : each | each includes: 'B' ] ifNone: [nil].
×
UNCOV
154
        self assert: bClone size equals: 2.
×
UNCOV
155
        self deny: (bClone includes: bClone).
×
UNCOV
156
        aInBClone := bClone detect: [ : each | each includes: 'A' ] ifNone: [nil].
×
UNCOV
157
        self assert: aInBClone size equals: 1.
×
UNCOV
158
        aInCClone := cClone detect: [ : each | each includes: 'A' ] ifNone: [nil].
×
UNCOV
159
        self assert: aInBClone identicalTo: aInCClone.
×
UNCOV
160
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc