@@ -139,6 +139,29 @@ test_that("Tests validateJSON", {
139139
140140})
141141
142+ # test object with special item names: self, private, super
143+ test_that(" Tests oneOf" , {
144+ special_json <-
145+ ' {"self": 123, "private": "red", "super": "something"}'
146+
147+ # test fromJSON
148+ special <- Special $ new()$ fromJSON(special_json )
149+ expect_equal(special $ item_self , 123 )
150+ expect_equal(special $ item_private , " red" )
151+ expect_equal(special $ item_super , " something" )
152+
153+ # test toJSONString
154+ expect_true(grepl(' "private"' , special $ toJSONString()))
155+ expect_true(grepl(' "self"' , special $ toJSONString()))
156+ expect_true(grepl(' "super"' , special $ toJSONString()))
157+
158+ # round trip test
159+ s1 <- Special $ new()$ fromJSONString(special_json )
160+ s2 <- Special $ new()$ fromJSONString(s1 $ toJSONString())
161+ expect_equal(s1 , s2 )
162+
163+ })
164+
142165test_that(" Tests oneOf" , {
143166 basque_pig_json <-
144167 ' {"className": "BasquePig", "color": "red"}'
@@ -153,8 +176,8 @@ test_that("Tests oneOf", {
153176 {"Name" : "Ada", "Occupation" : "Engineer"}
154177 ]'
155178
156- original_danish_pig = DanishPig $ new()$ fromJSON(danish_pig_json )
157- original_basque_pig = BasquePig $ new()$ fromJSON(basque_pig_json )
179+ original_danish_pig <- DanishPig $ new()$ fromJSON(danish_pig_json )
180+ original_basque_pig <- BasquePig $ new()$ fromJSON(basque_pig_json )
158181
159182 # test fromJSON, actual_tpye, actual_instance
160183 pig <- Pig $ new()
@@ -208,8 +231,8 @@ test_that("Tests anyOf", {
208231 {"Name" : "Ada", "Occupation" : "Engineer"}
209232 ]'
210233
211- original_danish_pig = DanishPig $ new()$ fromJSON(danish_pig_json )
212- original_basque_pig = BasquePig $ new()$ fromJSON(basque_pig_json )
234+ original_danish_pig <- DanishPig $ new()$ fromJSON(danish_pig_json )
235+ original_basque_pig <- BasquePig $ new()$ fromJSON(basque_pig_json )
213236
214237 # test fromJSON, actual_tpye, actual_instance
215238 pig <- AnyOfPig $ new()
0 commit comments