diff --git a/tests/test_parse_json.liq b/tests/test_parse_json.liq index 36002e25550983737c88d7f81eabf64744d11204..990a088d51f8d4275a4303132941598906b65ffe 100755 --- a/tests/test_parse_json.liq +++ b/tests/test_parse_json.liq @@ -26,7 +26,6 @@ let json.parse data = '{"show_id": "-1", "show_name": "Random Music"}' print("Set current show to '#{data.show_name}' (ID: #{data.show_id})") assertEquals("#{data.show_name}", "null") -# > Set current show to 'null' (ID: null) # Scenario 2: Works, when data types of the JSON have been defined let json.parse (data : { @@ -36,16 +35,12 @@ let json.parse (data : { print("Set current show to '#{data.show_name}' (ID: #{data.show_id})") assertEquals(data.show_name, "Random Music") assertEquals(data.show_id, "-1") -# # > Set current show to 'Random Music' (ID: -1) - # Scenario 3: Works, even when no data types have been defined let json.parse data = '{"show_id": "-1", "show_name": "Random Music"}' print("Set current show to '" ^ data.show_name ^ "' (ID: " ^ data.show_id ^ ")") assertEquals(data.show_name, "Random Music") assertEquals(data.show_id, "-1") -# # > Set current show to 'Random Music' (ID: -1) - # Scenario 4: Works, when variables have been accessed outside the string before let json.parse data = '{"show_id": "-1", "show_name": "Random Music"}' @@ -55,5 +50,12 @@ assertEquals(data.show_id, "-1") print("Set current show to '#{data.show_name}' (ID: #{data.show_id})") assertEquals(data.show_name, "Random Music") assertEquals(data.show_id, "-1") -# > Set current show to 'Random Music' (ID: -1) -# > Set current show to 'Random Music' (ID: -1) + +# Scenario 5: Allow `null` and optional values +let json.parse (data : { + show_id: string, + show_name: string?, + track_title: string? + }) = '{"show_id": "-1", "show_name": null}' +print("Set current show to '#{data.show_name}' (ID: #{data.show_id})") +assertEquals(data.show_id, "-1")