From 900ac32a51b41eb083621b929ccbc27bb2f58988 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Fri, 11 Oct 2024 18:15:04 +0530 Subject: [PATCH] Add tests for immutable types --- ballerina/tests/from_json_test.bal | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ballerina/tests/from_json_test.bal b/ballerina/tests/from_json_test.bal index 14325e7..a47abf0 100644 --- a/ballerina/tests/from_json_test.bal +++ b/ballerina/tests/from_json_test.bal @@ -98,6 +98,15 @@ isolated function testSimpleJsonToRecord3() returns Error? { test:assertEquals(r, {id: 4012, age: 27, name: {firstname: "John", lastname: "Doe"}}); } +type UserRecord3 ReadOnlyUserRecord2; + +@test:Config +isolated function testSimpleJsonToRecord4() returns Error? { + json user = {id: 4012, name: {firstname: "John", lastname: "Doe"}, age: 27}; + UserRecord3 r = check parseAsType(user); + test:assertEquals(r, {id: 4012, age: 27, name: {firstname: "John", lastname: "Doe"}}); +} + @test:Config isolated function testSimpleJsonToRecordWithProjection() returns Error? { json j = {"a": "hello", "b": 1};