From dae58ea14bcac09aade757a67d1102e075490d90 Mon Sep 17 00:00:00 2001 From: gimantha Date: Sat, 12 Sep 2020 11:39:43 +0530 Subject: [PATCH 1/4] Fix tests --- .../jvm/values/MapValueImpl.java | 2 +- .../langlib/test/LangLibValueTest.java | 40 +++++------ .../ForeachMapTypedBindingPatternsTests.java | 48 +++++++------- ...oreachRecordTypedBindingPatternsTests.java | 4 +- ...ForeachTableTypedBindingPatternsTests.java | 10 +-- .../test/resources/test-src/arraylib_test.bal | 66 +++++++++---------- .../test/resources/test-src/tablelib_test.bal | 8 +-- .../test/resources/test-src/valuelib_test.bal | 24 +++---- 8 files changed, 101 insertions(+), 101 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java index 11217ce7f46e..ac2cff5af25f 100644 --- a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java @@ -412,7 +412,7 @@ public Object frozenCopy(Map refs) { @Override public String stringValue(BLink parent) { - StringJoiner sj = new StringJoiner(", "); + StringJoiner sj = new StringJoiner(","); for (Map.Entry kvEntry : this.entrySet()) { K key = kvEntry.getKey(); V value = kvEntry.getValue(); diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java index 872dafd8e374..99a39369a4be 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java @@ -132,8 +132,8 @@ public void testToString() { Assert.assertEquals(array.getString(i++), ""); Assert.assertEquals(array.getString(i++), "true"); Assert.assertEquals(array.getString(i++), "345.2425341"); - Assert.assertEquals(array.getString(i++), "{\"a\":\"STRING\", \"b\":12, \"c\":12.4, \"d\":true, " + - "\"e\":{\"x\":\"x\", \"y\":null}}"); + Assert.assertEquals(array.getString(i++), "{\"a\":\"STRING\",\"b\":12,\"c\":12.4,\"d\":true," + + "\"e\":{\"x\":\"x\",\"y\":null}}"); Assert.assertEquals(array.getString(i++), "" + "Empire BurlesqueBob Dylan" + @@ -147,29 +147,29 @@ public void testToString() { Assert.assertEquals(array.getString(i++), "Rola from MMV"); Assert.assertEquals(array.getString(i++), "[object Student,Rola from MMV]"); Assert.assertEquals(array.getString(i++), - "{\"name\":\"Gima\", \"address\":{\"country\":\"Sri Lanka\", \"city\":\"Colombo\", " + - "\"street\":\"Palm Grove\"}, \"age\":12}"); + "{\"name\":\"Gima\",\"address\":{\"country\":\"Sri Lanka\",\"city\":\"Colombo\"," + + "\"street\":\"Palm Grove\"},\"age\":12}"); Assert.assertEquals(array.getString(i), - "{\"varInt\":6, " + - "\"varFloat\":6.0, " + - "\"varStr\":\"toString\", " + - "\"varNil\":null, " + - "\"varBool\":true, " + - "\"varDecimal\":345.2425341, " + - "\"varjson\":{\"a\":\"STRING\", \"b\":12, \"c\":12.4, \"d\":true, " + - "\"e\":{\"x\":\"x\", \"y\":null}}, " + + "{\"varInt\":6," + + "\"varFloat\":6.0," + + "\"varStr\":\"toString\"," + + "\"varNil\":null," + + "\"varBool\":true," + + "\"varDecimal\":345.2425341," + + "\"varjson\":{\"a\":\"STRING\",\"b\":12,\"c\":12.4,\"d\":true," + + "\"e\":{\"x\":\"x\",\"y\":null}}," + "\"varXml\":`Empire Burlesque" + "Bob DylanHide your heart" + "Bonnie TylerGreatest Hits" + - "Dolly Parton`, " + - "\"varArr\":[\"str\",23,23.4,true], " + + "Dolly Parton`," + + "\"varArr\":[\"str\",23,23.4,true]," + "\"varErr\":error FirstError (\"Reason1\", " + - "message=\"Test passing error union to a function\"), " + - "\"varObj\":object Student, " + - "\"varObj2\":Rola from MMV, " + - "\"varObjArr\":[object Student,Rola from MMV], " + - "\"varRecord\":{\"name\":\"Gima\", \"address\":{\"country\":\"Sri Lanka\", " + - "\"city\":\"Colombo\", \"street\":\"Palm Grove\"}, \"age\":12}}"); + "message=\"Test passing error union to a function\")," + + "\"varObj\":object Student," + + "\"varObj2\":Rola from MMV," + + "\"varObjArr\":[object Student,Rola from MMV]," + + "\"varRecord\":{\"name\":\"Gima\",\"address\":{\"country\":\"Sri Lanka\"," + + "\"city\":\"Colombo\",\"street\":\"Palm Grove\"},\"age\":12}}"); } @Test diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachMapTypedBindingPatternsTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachMapTypedBindingPatternsTests.java index 151bd0384d1c..728786b847b3 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachMapTypedBindingPatternsTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachMapTypedBindingPatternsTests.java @@ -148,16 +148,16 @@ public void testConstrainedMapWithTupleInTupleWithAnyType() { public void testUnconstrainedMapWithRecordInTupleWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordInTupleWithoutType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1, \"v\":\"A\"} 1:3 {\"i\":2, \"v\":\"B\"} " + - "2:4 {\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1,\"v\":\"A\"} 1:3 {\"i\":2,\"v\":\"B\"} " + + "2:4 {\"i\":3,\"v\":\"C\"} "); } @Test public void testUnconstrainedMapWithRecordInTupleWithType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordInTupleWithType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1, \"v\":\"A\"} 1:3 {\"i\":2, \"v\":\"B\"} 2:4 " + - "{\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1,\"v\":\"A\"} 1:3 {\"i\":2,\"v\":\"B\"} 2:4 " + + "{\"i\":3,\"v\":\"C\"} "); } @Test @@ -178,24 +178,24 @@ public void testConstrainedMapWithRecordInTupleWithType() { public void testConstrainedMapWithRecordInTupleWithAnyType() { BValue[] returns = BRunUtil.invoke(program, "testConstrainedMapWithRecordInTupleWithAnyType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1, \"v\":\"A\"} 1:3 {\"i\":2, \"v\":\"B\"} " + - "2:4 {\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:2 {\"i\":1,\"v\":\"A\"} 1:3 {\"i\":2,\"v\":\"B\"} " + + "2:4 {\"i\":3,\"v\":\"C\"} "); } @Test public void testUnconstrainedMapWithRecordWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordWithoutType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":\"A\"} 1:{\"i\":2, \"v\":\"B\"} " + - "2:{\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":\"A\"} 1:{\"i\":2,\"v\":\"B\"} " + + "2:{\"i\":3,\"v\":\"C\"} "); } @Test public void testUnconstrainedMapWithRecordWithType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordWithType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":\"A\"} 1:{\"i\":2, \"v\":\"B\"} " + - "2:{\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":\"A\"} 1:{\"i\":2,\"v\":\"B\"} " + + "2:{\"i\":3,\"v\":\"C\"} "); } @Test @@ -216,24 +216,24 @@ public void testConstrainedMapWithRecordWithType() { public void testConstrainedMapWithRecordWithAnyType() { BValue[] returns = BRunUtil.invoke(program, "testConstrainedMapWithRecordWithAnyType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":\"A\"} 1:{\"i\":2, " + - "\"v\":\"B\"} 2:{\"i\":3, \"v\":\"C\"} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":\"A\"} 1:{\"i\":2," + + "\"v\":\"B\"} 2:{\"i\":3,\"v\":\"C\"} "); } @Test public void testUnconstrainedMapWithRecordInRecordWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordInRecordWithoutType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2, \"v\":{\"i\":1, \"v\":\"A\"}} 1:{\"i\":3, " + - "\"v\":{\"i\":2, \"v\":\"B\"}} 2:{\"i\":4, \"v\":{\"i\":3, \"v\":\"C\"}} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2,\"v\":{\"i\":1,\"v\":\"A\"}} 1:{\"i\":3," + + "\"v\":{\"i\":2,\"v\":\"B\"}} 2:{\"i\":4,\"v\":{\"i\":3,\"v\":\"C\"}} "); } @Test public void testUnconstrainedMapWithRecordInRecordWithType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithRecordInRecordWithType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2, \"v\":{\"i\":1, \"v\":\"A\"}} 1:{\"i\":3, " + - "\"v\":{\"i\":2, \"v\":\"B\"}} 2:{\"i\":4, \"v\":{\"i\":3, \"v\":\"C\"}} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2,\"v\":{\"i\":1,\"v\":\"A\"}} 1:{\"i\":3," + + "\"v\":{\"i\":2,\"v\":\"B\"}} 2:{\"i\":4,\"v\":{\"i\":3,\"v\":\"C\"}} "); } @Test @@ -254,24 +254,24 @@ public void testConstrainedMapWithRecordInRecordWithType() { public void testConstrainedMapWithRecordInRecordWithAnyType() { BValue[] returns = BRunUtil.invoke(program, "testConstrainedMapWithRecordInRecordWithAnyType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2, \"v\":{\"i\":1, \"v\":\"A\"}} 1:{\"i\":3, " + - "\"v\":{\"i\":2, \"v\":\"B\"}} 2:{\"i\":4, \"v\":{\"i\":3, \"v\":\"C\"}} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":2,\"v\":{\"i\":1,\"v\":\"A\"}} 1:{\"i\":3," + + "\"v\":{\"i\":2,\"v\":\"B\"}} 2:{\"i\":4,\"v\":{\"i\":3,\"v\":\"C\"}} "); } @Test public void testUnconstrainedMapWithTupleInRecordWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithTupleInRecordWithoutType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":1 A} 1:{\"i\":2, \"v\":2 B} " + - "2:{\"i\":3, \"v\":3 C} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":1 A} 1:{\"i\":2,\"v\":2 B} " + + "2:{\"i\":3,\"v\":3 C} "); } @Test public void testUnconstrainedMapWithTupleInRecordWithType() { BValue[] returns = BRunUtil.invoke(program, "testUnconstrainedMapWithTupleInRecordWithType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":1 A} 1:{\"i\":2, \"v\":2 B} " + - "2:{\"i\":3, \"v\":3 C} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":1 A} 1:{\"i\":2,\"v\":2 B} " + + "2:{\"i\":3,\"v\":3 C} "); } @Test @@ -292,8 +292,8 @@ public void testConstrainedMapWithTupleInRecordWithType() { public void testConstrainedMapWithTupleInRecordWithAnyType() { BValue[] returns = BRunUtil.invoke(program, "testConstrainedMapWithTupleInRecordWithAnyType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1, \"v\":1 A} 1:{\"i\":2, \"v\":2 B} " + - "2:{\"i\":3, \"v\":3 C} "); + Assert.assertEquals(returns[0].stringValue(), "0:{\"i\":1,\"v\":1 A} 1:{\"i\":2,\"v\":2 B} " + + "2:{\"i\":3,\"v\":3 C} "); } @Test diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachRecordTypedBindingPatternsTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachRecordTypedBindingPatternsTests.java index 3991b4b63242..ec15ffc45f91 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachRecordTypedBindingPatternsTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachRecordTypedBindingPatternsTests.java @@ -57,14 +57,14 @@ public void testSimpleRecordWithType() { public void testRecordInRecordWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testRecordInRecordWithoutType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:2 1:B 2:{\"i\":1, \"s\":\"A\", \"f\":1.0} "); + Assert.assertEquals(returns[0].stringValue(), "0:2 1:B 2:{\"i\":1,\"s\":\"A\",\"f\":1.0} "); } @Test public void testRecordInRecordWithType() { BValue[] returns = BRunUtil.invoke(program, "testRecordInRecordWithType"); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "0:2 1:B 2:{\"i\":1, \"s\":\"A\", \"f\":1.0} "); + Assert.assertEquals(returns[0].stringValue(), "0:2 1:B 2:{\"i\":1,\"s\":\"A\",\"f\":1.0} "); } @Test diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachTableTypedBindingPatternsTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachTableTypedBindingPatternsTests.java index 116c4002fbd8..6ec15fbbe70b 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachTableTypedBindingPatternsTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachTableTypedBindingPatternsTests.java @@ -46,8 +46,8 @@ public void testTableWithoutType() { BValue[] returns = BRunUtil.invoke(program, "testTableWithoutType"); Assert.assertEquals(returns.length, 1); Assert.assertEquals(returns[0].stringValue(), - "0:{\"id\":1, \"name\":\"Mary\", \"salary\":300.5} 1:{\"id\":2, \"name\":\"John\", " + - "\"salary\":200.5} 2:{\"id\":3, \"name\":\"Jim\", \"salary\":330.5} "); + "0:{\"id\":1,\"name\":\"Mary\",\"salary\":300.5} 1:{\"id\":2,\"name\":\"John\"," + + "\"salary\":200.5} 2:{\"id\":3,\"name\":\"Jim\",\"salary\":330.5} "); } @Test @@ -55,9 +55,9 @@ public void testTableWithType() { BValue[] returns = BRunUtil.invoke(program, "testTableWithType"); Assert.assertEquals(returns.length, 1); Assert.assertEquals(returns[0].stringValue(), - "0:{\"id\":1, \"name\":\"Mary\", \"salary\":300.5} " + - "1:{\"id\":2, \"name\":\"John\", \"salary\":200.5} " + - "2:{\"id\":3, \"name\":\"Jim\", \"salary\":330.5} "); + "0:{\"id\":1,\"name\":\"Mary\",\"salary\":300.5} " + + "1:{\"id\":2,\"name\":\"John\",\"salary\":200.5} " + + "2:{\"id\":3,\"name\":\"Jim\",\"salary\":330.5} "); } @Test diff --git a/langlib/langlib-test/src/test/resources/test-src/arraylib_test.bal b/langlib/langlib-test/src/test/resources/test-src/arraylib_test.bal index ad2c21735924..3284e7f1ada2 100644 --- a/langlib/langlib-test/src/test/resources/test-src/arraylib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/arraylib_test.bal @@ -552,15 +552,15 @@ function testSort1() { }); assertValueEquality(sortedArr[0].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(sortedArr[1].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr[2].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr[3].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(sortedArr[4].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(studentArr, sortedArr); Student[] sortedArr2 = studentArr.sort(array:DESCENDING, function(Student s) returns string? { @@ -568,15 +568,15 @@ function testSort1() { }); assertValueEquality(sortedArr2[0].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr2[1].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr2[2].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(sortedArr2[3].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr2[4].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(studentArr, sortedArr2); Student[] sortedArr3 = studentArr.sort(array:ASCENDING, function(Student s) returns float? { @@ -584,15 +584,15 @@ function testSort1() { }); assertValueEquality(sortedArr3[0].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(sortedArr3[1].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr3[2].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr3[3].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr3[4].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(studentArr, sortedArr3); Student[] sortedArr4 = studentArr.sort(array:ASCENDING, function(Student s) returns decimal { @@ -600,15 +600,15 @@ function testSort1() { }); assertValueEquality(sortedArr4[0].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr4[1].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr4[2].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(sortedArr4[3].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr4[4].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(studentArr, sortedArr4); Student[] sortedArr5 = studentArr.sort(array:ASCENDING, function(Student s) returns boolean { @@ -616,15 +616,15 @@ function testSort1() { }); assertValueEquality(sortedArr5[0].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr5[1].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr5[2].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(sortedArr5[3].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr5[4].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(studentArr, sortedArr5); @@ -685,15 +685,15 @@ function testSort5() { }); assertValueEquality(sortedArr[0].toString(), - "{\"id\":3, \"fname\":\"Kate\", \"fee\":5000.56, \"impact\":0.4, \"isUndergrad\":false}"); + "{\"id\":3,\"fname\":\"Kate\",\"fee\":5000.56,\"impact\":0.4,\"isUndergrad\":false}"); assertValueEquality(sortedArr[1].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr[2].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(sortedArr[3].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr[4].toString(), - "{\"id\":20, \"fname\":null, \"fee\":2000.56, \"impact\":0.45, \"isUndergrad\":false}"); + "{\"id\":20,\"fname\":null,\"fee\":2000.56,\"impact\":0.45,\"isUndergrad\":false}"); assertValueEquality(studentArr, sortedArr); } @@ -805,14 +805,14 @@ function testSort6() { }); assertValueEquality(sortedArr10[0].toString(), - "{\"id\":1, \"fname\":\"Amber\", \"fee\":10000.56, \"impact\":0.127, \"isUndergrad\":true}"); + "{\"id\":1,\"fname\":\"Amber\",\"fee\":10000.56,\"impact\":0.127,\"isUndergrad\":true}"); assertValueEquality(sortedArr10[1].toString(), "Anne"); assertValueEquality(sortedArr10[2].toString(), - "{\"id\":2, \"fname\":\"Dan\", \"fee\":null, \"impact\":0.3, \"isUndergrad\":true}"); + "{\"id\":2,\"fname\":\"Dan\",\"fee\":null,\"impact\":0.3,\"isUndergrad\":true}"); assertValueEquality(sortedArr10[3].toString(), "Frank"); assertValueEquality(sortedArr10[4].toString(), "James"); assertValueEquality(sortedArr10[5].toString(), - "{\"id\":10, \"fname\":\"Kate\", \"fee\":NaN, \"impact\":0.146, \"isUndergrad\":false}"); + "{\"id\":10,\"fname\":\"Kate\",\"fee\":NaN,\"impact\":0.146,\"isUndergrad\":false}"); assertValueEquality(sortedArr10, arr7); int[] sortedArr11 = array:sort(arr5); diff --git a/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal b/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal index 729fb59ce301..aec6fe17914c 100644 --- a/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal @@ -432,8 +432,8 @@ function testAddValidDataWithMapConstrTbl() returns boolean { PersonAnyTable personTbl = engineerTbl; Intern intern1 = { name: "John", age: 23, intern: true, salary: 100 }; personTbl.add(intern1); - testPassed = testPassed && personTbl.toString() == "[{\"name\":\"Lisa\", \"age\":22, \"intern\":true}," + - "{\"name\":\"Jonas\", \"age\":21, \"intern\":false},{\"name\":\"John\", \"age\":23, \"intern\":true, " + + testPassed = testPassed && personTbl.toString() == "[{\"name\":\"Lisa\",\"age\":22,\"intern\":true}," + + "{\"name\":\"Jonas\",\"age\":21,\"intern\":false},{\"name\":\"John\",\"age\":23,\"intern\":true," + "\"salary\":100}]"; return testPassed; } @@ -535,8 +535,8 @@ function testPutValidDataWithMapConstrTbl() returns boolean { PersonAnyTable personTbl = engineerTbl; Intern intern1 = { name: "John", age: 23, intern: true, salary: 100 }; personTbl.put(intern1); - testPassed = testPassed && personTbl.toString() == "[{\"name\":\"Lisa\", \"age\":22, \"intern\":true}," + - "{\"name\":\"Jonas\", \"age\":21, \"intern\":false},{\"name\":\"John\", \"age\":23, \"intern\":true, " + + testPassed = testPassed && personTbl.toString() == "[{\"name\":\"Lisa\",\"age\":22,\"intern\":true}," + + "{\"name\":\"Jonas\",\"age\":21,\"intern\":false},{\"name\":\"John\",\"age\":23,\"intern\":true," + "\"salary\":100}]"; return testPassed; } diff --git a/langlib/langlib-test/src/test/resources/test-src/valuelib_test.bal b/langlib/langlib-test/src/test/resources/test-src/valuelib_test.bal index 076b06589abc..b60d0e8545fa 100644 --- a/langlib/langlib-test/src/test/resources/test-src/valuelib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/valuelib_test.bal @@ -357,8 +357,8 @@ function testToStringMethodForTable() { { id: 2, age: 20, salary: 300.5, name: "John", married: true } ]; - assertEquality("[{\"id\":1, \"age\":30, \"salary\":300.5, \"name\":\"Mary\", \"married\":true}," - + "{\"id\":2, \"age\":20, \"salary\":300.5, \"name\":\"John\", \"married\":true}]", employeeTable.toString()); + assertEquality("[{\"id\":1,\"age\":30,\"salary\":300.5,\"name\":\"Mary\",\"married\":true}," + + "{\"id\":2,\"age\":20,\"salary\":300.5,\"name\":\"John\",\"married\":true}]", employeeTable.toString()); } public function xmlSequenceFragmentToString() returns string { @@ -595,12 +595,12 @@ function testFromJsonWIthTypeNegative() { } function testFromJsonWithTypeRecord1() { - string str = "{\"name\":\"Name\", \"age\":35}"; + string str = "{\"name\":\"Name\",\"age\":35}"; json j = str.fromJsonString(); Student2|error p = j.fromJsonWithType(Student2); assert(p is Student2, true); - assert(p.toString(), "{\"name\":\"Name\", \"age\":35}"); + assert(p.toString(), "{\"name\":\"Name\",\"age\":35}"); } type Student3 record { @@ -633,12 +633,12 @@ type Foo6 record { }; function testFromJsonWithTypeRecord2() { - string str = "{\"name\":\"Name\", \"age\":35}"; + string str = "{\"name\":\"Name\",\"age\":35}"; json j = str.fromJsonString(); Student3|error p = j.fromJsonWithType(Student3); assert(p is Student3, true); - assert(p.toString(), "{\"name\":\"Name\", \"age\":35}"); + assert(p.toString(), "{\"name\":\"Name\",\"age\":35}"); } function testFromJsonWithTypeRecord3() { @@ -660,7 +660,7 @@ function testFromJsonWithTypeRecord3() { type Student2Or3 Student2|Student3; function testFromJsonWithTypeAmbiguousTargetType() { - string str = "{\"name\":\"Name\", \"age\":35}"; + string str = "{\"name\":\"Name\",\"age\":35}"; json j = str.fromJsonString(); Student3|error p = j.fromJsonWithType(Student2Or3); assert(p is error, true); @@ -800,7 +800,7 @@ function testFromJsonStringWithTypeJson() { } function testFromJsonStringWithTypeRecord() { - string str = "{\"name\":\"Name\", \"age\":35}"; + string str = "{\"name\":\"Name\",\"age\":35}"; Student3|error studentOrError = str.fromJsonStringWithType(Student3); assert(studentOrError is Student3, true); @@ -809,13 +809,13 @@ function testFromJsonStringWithTypeRecord() { } function testFromJsonStringWithAmbiguousType() { - string str = "{\"name\":\"Name\", \"age\":35}"; + string str = "{\"name\":\"Name\",\"age\":35}"; Student3|error p = str.fromJsonStringWithType(Student2Or3); assert(p is error, true); } function testFromJsonStringWithTypeMap() { - string s = "{\"title\":\"Some\", \"year\":2010}"; + string s = "{\"title\":\"Some\",\"year\":2010}"; map|error movieMap = s.fromJsonStringWithType(MapOfAnyData); map movieMap2 = > movieMap; assert(movieMap2["title"], "Some"); @@ -823,7 +823,7 @@ function testFromJsonStringWithTypeMap() { } function testFromJsonStringWithTypeStringArray() { - string s = "[\"Hello\", \"World\"]"; + string s = "[\"Hello\",\"World\"]"; string[]|error a = s.fromJsonStringWithType(StringArray); string[] a2 = a; assert(a2.length(), 2); @@ -945,7 +945,7 @@ function testToStringOnCycles() { y["1"] = x; y["2"] = arr; arr.push(x); - assert(x.toString(), "{\"ee\":3, \"1\":{\"qq\":5, \"1\":..., \"2\":[2,3,5,...]}}"); + assert(x.toString(), "{\"ee\":3,\"1\":{\"qq\":5,\"1\":...,\"2\":[2,3,5,...]}}"); } function assert(anydata actual, anydata expected) { From 07d452f3cd3804698ab28b9faee2ef9eb66bbdc2 Mon Sep 17 00:00:00 2001 From: Mohan Date: Sat, 12 Sep 2020 11:58:26 +0530 Subject: [PATCH 2/4] Fix testcases according to the changes in spacing for map --- .../ballerinalang/jvm/values/MapValueImpl.java | 2 +- .../org/ballerinalang/stdlib/io/IOPrintTest.java | 2 +- .../CheckPanicExpressionOperatorTest.java | 2 +- .../literals/NullLiteralUsageTest.java | 4 ++-- .../test/javainterop/basic/StaticMethodTest.java | 2 +- .../function/ArgumentParserPositiveTest.java | 4 ++-- .../test/record/RecordValueTest.java | 4 ++-- .../test/types/map/BMapValueTest.java | 2 +- .../test/types/string/BStringTableValueTest.java | 4 ++-- .../test/types/string/BStringToStringTest.java | 4 ++-- .../table/TableWithRecordKeySpecifierTest.java | 4 ++-- .../table/TableWithXMLKeySpecifierTest.java | 2 +- .../types/tuples/TupleRestDescriptorTest.java | 8 ++++---- .../test/types/xml/XMLAttributesTest.java | 2 +- .../expressions/typecast/type-casting.bal | 2 +- .../src/test/resources/test-src/jvm/types.bal | 2 +- .../statements/arrays/array-fill-test.bal | 2 +- .../test-src/types/any/any-type-success.bal | 4 ++-- .../test-src/types/anydata/anydata_test.bal | 10 +++++----- .../types/table/map-constraint-table-value.bal | 4 ++-- .../table/record-constraint-table-value.bal | 16 ++++++++-------- .../types/table/record-type-table-key.bal | 6 +++--- .../types/table/tables-as-func-arguments.bal | 16 ++++++++-------- .../test-src/types/table/xml-type-table-key.bal | 4 ++-- 24 files changed, 56 insertions(+), 56 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java index 11217ce7f46e..ac2cff5af25f 100644 --- a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/MapValueImpl.java @@ -412,7 +412,7 @@ public Object frozenCopy(Map refs) { @Override public String stringValue(BLink parent) { - StringJoiner sj = new StringJoiner(", "); + StringJoiner sj = new StringJoiner(","); for (Map.Entry kvEntry : this.entrySet()) { K key = kvEntry.getKey(); V value = kvEntry.getValue(); diff --git a/stdlib/io/src/test/java/org/ballerinalang/stdlib/io/IOPrintTest.java b/stdlib/io/src/test/java/org/ballerinalang/stdlib/io/IOPrintTest.java index 4829efb824a1..a72d1cb5e566 100644 --- a/stdlib/io/src/test/java/org/ballerinalang/stdlib/io/IOPrintTest.java +++ b/stdlib/io/src/test/java/org/ballerinalang/stdlib/io/IOPrintTest.java @@ -288,7 +288,7 @@ public void testFormatIntArray() { fArgs.add(0, arr); BValue[] args = {new BString("%s"), fArgs}; BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args); - Assert.assertEquals(returns[0].stringValue(), "[111, 222, 333]"); + Assert.assertEquals(returns[0].stringValue(), "[111,222,333]"); } @Test diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkpanicexpr/CheckPanicExpressionOperatorTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkpanicexpr/CheckPanicExpressionOperatorTest.java index d3257d3bc7a0..52e388f2c3c9 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkpanicexpr/CheckPanicExpressionOperatorTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkpanicexpr/CheckPanicExpressionOperatorTest.java @@ -52,7 +52,7 @@ public void testSafeAssignmentBasics1() { } @Test(expectedExceptions = {BLangRuntimeException.class}, - expectedExceptionsMessageRegExp = "error: Generic Error \\{\"fatal\":true, " + + expectedExceptionsMessageRegExp = "error: Generic Error \\{\"fatal\":true," + "\"message\":\"Something Went Wrong.*") public void testSafeAssignmentBasics2() { BValue[] arg = {new BInteger(2)}; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/literals/NullLiteralUsageTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/literals/NullLiteralUsageTest.java index 44ac55721402..20e9e7755c9b 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/literals/NullLiteralUsageTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/literals/NullLiteralUsageTest.java @@ -104,13 +104,13 @@ public void testNullStringRepresentation2() { @Test public void testNullStringRepresentation3() { BValue[] returns = BRunUtil.invoke(result, "testNullStringRepresentation3"); - assertEquals(returns[0].stringValue(), "{\"name\":\"John Doe\", \"age\":25, \"location\":null}"); + assertEquals(returns[0].stringValue(), "{\"name\":\"John Doe\",\"age\":25,\"location\":null}"); } @Test public void testNullStringRepresentation4() { BValue[] returns = BRunUtil.invoke(result, "testNullStringRepresentation4"); - assertEquals(returns[0].stringValue(), "{\"name\":\"John Doe\", \"age\":25, \"location\":null}"); + assertEquals(returns[0].stringValue(), "{\"name\":\"John Doe\",\"age\":25,\"location\":null}"); } @Test diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/StaticMethodTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/StaticMethodTest.java index 1b864a470a92..c60b5d32fd34 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/StaticMethodTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/StaticMethodTest.java @@ -135,7 +135,7 @@ public void testReturnObjectValueOrError() { public void testMapValueOrErrorReturn() { BValue[] returns = BRunUtil.invoke(result, "testUnionReturn"); Assert.assertEquals(returns[0].stringValue(), - "{\"resources\":[{\"path\":\"basePath\", \"method\":\"Method string\"}]}"); + "{\"resources\":[{\"path\":\"basePath\",\"method\":\"Method string\"}]}"); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java index b8ffafc67108..c5f027bc0806 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java @@ -211,7 +211,7 @@ public void testMainWithOptionalParamsBothSpecified() { compileResult = BCompileUtil.compile(MAIN_FUNCTION_TEST_SRC_DIR + "test_main_with_optional_defaultable_param.bal"); String output = runMain(compileResult, new String[]{"-s=ballerina", "-m={\"eleven\":11,\"twelve\":12}"}); - Assert.assertEquals(output, "string value: ballerina {\"eleven\":11, \"twelve\":12}", + Assert.assertEquals(output, "string value: ballerina {\"eleven\":11,\"twelve\":12}", "evaluated to invalid value"); } @@ -278,7 +278,7 @@ public Object[][] optionalParamArgAndResult() { public Object[][] optionalDefaultableParamArgAndResult() { return new Object[][]{ {"-s=hello world", "string value: hello world m is nil"}, - {"-m={\"one\":1,\"two\":2}", "string value: s is nil {\"one\":1, \"two\":2}"} + {"-m={\"one\":1,\"two\":2}", "string value: s is nil {\"one\":1,\"two\":2}"} }; } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/RecordValueTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/RecordValueTest.java index d36ba6e7bd21..b0f8cb25496e 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/RecordValueTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/RecordValueTest.java @@ -93,7 +93,7 @@ public void testRecordOperations_1() { Assert.assertEquals(person.size(), 3); Assert.assertFalse(person.isEmpty()); - Assert.assertEquals(person.stringValue(null), "{\"name\":\"John\", \"age\":30, \"last-name\":\"Doe\"}"); + Assert.assertEquals(person.stringValue(null), "{\"name\":\"John\",\"age\":30,\"last-name\":\"Doe\"}"); // set optional field person.put(StringUtils.fromString("spouse"), StringUtils.fromString("Jane")); @@ -150,7 +150,7 @@ public void testRecordOperations_2() { Assert.assertFalse(person.isEmpty()); Assert.assertEquals(person.stringValue(null), - "{\"name\":\"Jane\", \"age\":25, \"spouse\":\"John\", \"gender\":\"female\"}"); + "{\"name\":\"Jane\",\"age\":25,\"spouse\":\"John\",\"gender\":\"female\"}"); } @Test(expectedExceptions = {UnsupportedOperationException.class}) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/map/BMapValueTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/map/BMapValueTest.java index a59f65e01df3..04f26b54dbc2 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/map/BMapValueTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/map/BMapValueTest.java @@ -208,7 +208,7 @@ public void testBMapToString() { map.put(StringUtils.fromString("key1"), 1); map.put(StringUtils.fromString("key2"), StringUtils.fromString("foo")); map.put(StringUtils.fromString("key3"), XMLFactory.parse("hello")); - Assert.assertEquals(map.stringValue(null), "{\"key1\":1, \"key2\":\"foo\", \"key3\":`hello`}"); + Assert.assertEquals(map.stringValue(null), "{\"key1\":1,\"key2\":\"foo\",\"key3\":`hello`}"); } @Test(dependsOnMethods = "testGrammar") diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringTableValueTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringTableValueTest.java index 43088b694ee6..1829b5902d08 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringTableValueTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringTableValueTest.java @@ -35,11 +35,11 @@ public void setup() { @Test public void testTableGeneration() { - testAndAssert("testTableGeneration", 122); + testAndAssert("testTableGeneration", 116); } @Test public void testTableWithArrayGeneration() { - testAndAssert("testTableWithArrayGeneration", 56); + testAndAssert("testTableWithArrayGeneration", 55); } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringToStringTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringToStringTest.java index deb17b837dac..eca5c09509fc 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringToStringTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/string/BStringToStringTest.java @@ -44,12 +44,12 @@ public void testFunctionPointerToString() { @Test public void testMapToString() { - testAndAssert("testMapToString", 84); + testAndAssert("testMapToString", 81); } @Test public void testMapToStringWithSymbol() { - testAndAssert("testMapToStringWithSymbol", 87); + testAndAssert("testMapToStringWithSymbol", 84); } @Test diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithRecordKeySpecifierTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithRecordKeySpecifierTest.java index 12614fc10221..ee72480ff853 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithRecordKeySpecifierTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithRecordKeySpecifierTest.java @@ -55,7 +55,7 @@ public void testKeylessTable() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.table\\}KeyNotFound \\{\"message\":\"cannot " + - "find key '\\{\"fname\":\"Sanjiva\", \"lname\":\"Clark\"}'.*") + "find key '\\{\"fname\":\"Sanjiva\",\"lname\":\"Clark\"}'.*") public void testMemberAccessWithInvalidSingleKey() { BRunUtil.invoke(result, "testMemberAccessWithInvalidSingleKey"); Assert.fail(); @@ -63,7 +63,7 @@ public void testMemberAccessWithInvalidSingleKey() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.table\\}KeyNotFound \\{\"message\":\"cannot " + - "find key '18 \\{\"fname\":\"Sanjiva\", \"lname\":\"Clark\"}'.*") + "find key '18 \\{\"fname\":\"Sanjiva\",\"lname\":\"Clark\"}'.*") public void testMemberAccessWithInvalidMultiKey() { BRunUtil.invoke(result, "testMemberAccessWithInvalidMultiKey"); Assert.fail(); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithXMLKeySpecifierTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithXMLKeySpecifierTest.java index 00937cf2746e..71f59dc08023 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithXMLKeySpecifierTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/table/TableWithXMLKeySpecifierTest.java @@ -58,7 +58,7 @@ public void testMemberAccessWithInvalidSingleKey() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.table\\}KeyNotFound \\{\"message\":\"cannot " + - "find key '245 \\{\"fname\":\"Sanjiva\", \"lname\":\"Weerawarana\"}'.*") + "find key '245 \\{\"fname\":\"Sanjiva\",\"lname\":\"Weerawarana\"}'.*") public void testMemberAccessWithInvalidMultiKey() { BRunUtil.invoke(result, "testMemberAccessWithInvalidXMLMultiKey"); Assert.fail(); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/tuples/TupleRestDescriptorTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/tuples/TupleRestDescriptorTest.java index 4a47fbd729a5..37c7d7a7c271 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/tuples/TupleRestDescriptorTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/tuples/TupleRestDescriptorTest.java @@ -65,16 +65,16 @@ public void testTupleAssignmentWithOnlyRestDescriptor() { public void testTupleCovarianceWithRestDescriptor() { BValue[] returns = BRunUtil.invoke(result, "tupleCovarianceWithRestDescriptor", new BValue[]{}); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "s {\"name\":\"John\", \"intern\":true} {\"name\":\"John\", " + - "\"intern\":true} {\"name\":\"John\", \"intern\":true} "); + Assert.assertEquals(returns[0].stringValue(), "s {\"name\":\"John\",\"intern\":true} {\"name\":\"John\"," + + "\"intern\":true} {\"name\":\"John\",\"intern\":true} "); } @Test(description = "Test tuple covariance with only rest descriptor") public void tupleCovarianceWithOnlyRestDescriptor() { BValue[] returns = BRunUtil.invoke(result, "tupleCovarianceWithOnlyRestDescriptor", new BValue[]{}); Assert.assertEquals(returns.length, 1); - Assert.assertEquals(returns[0].stringValue(), "{\"name\":\"John\", \"intern\":true} {\"name\":\"John\", " + - "\"intern\":true} {\"name\":\"John\", \"intern\":true} "); + Assert.assertEquals(returns[0].stringValue(), "{\"name\":\"John\",\"intern\":true} {\"name\":\"John\"," + + "\"intern\":true} {\"name\":\"John\",\"intern\":true} "); } @Test(description = "Test function invocation with tuples with rest descriptor") diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAttributesTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAttributesTest.java index dee4db55a947..164f446e298e 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAttributesTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAttributesTest.java @@ -269,7 +269,7 @@ public void testPrintAttribMap() { System.setOut(new PrintStream(outContent)); BRunUtil.invoke(xmlAttrProgFile, "testPrintAttribMap"); Assert.assertEquals(outContent.toString(), - "{\"{http://www.w3.org/2000/xmlns/}xmlns\":\"http://sample.com/wso2/c1\", \"name\":\"Foo\"}", + "{\"{http://www.w3.org/2000/xmlns/}xmlns\":\"http://sample.com/wso2/c1\",\"name\":\"Foo\"}", "Invalid attribute map printed"); } finally { try { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/typecast/type-casting.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/typecast/type-casting.bal index de537807cada..1014f2103ba1 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/typecast/type-casting.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/typecast/type-casting.bal @@ -502,7 +502,7 @@ function testAnyToTable(){ any anyValue = tb; var casted = > anyValue; table|error castedValue = casted; - assertEquality("[{\"id\":1, \"name\":\"Jane\"},{\"id\":2, \"name\":\"Anne\"}]", castedValue.toString()); + assertEquality("[{\"id\":1,\"name\":\"Jane\"},{\"id\":2,\"name\":\"Anne\"}]", castedValue.toString()); } type Employee record { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/jvm/types.bal b/tests/jballerina-unit-test/src/test/resources/test-src/jvm/types.bal index 174e1cf32dba..9d511c66cb7f 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/jvm/types.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/jvm/types.bal @@ -130,7 +130,7 @@ function tableFunc(){ { name: "Mary", physics: 90, chemistry: 87 } ]; - assertEquality("[{\"name\":\"Mary\", \"physics\":90, \"chemistry\":87}]", gradesTable.toString()); + assertEquality("[{\"name\":\"Mary\",\"physics\":90,\"chemistry\":87}]", gradesTable.toString()); } function arrayFunc(string[] strs) returns Grades[] { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/arrays/array-fill-test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/arrays/array-fill-test.bal index a99389dfad98..a691576e8eef 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/arrays/array-fill-test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/arrays/array-fill-test.bal @@ -104,7 +104,7 @@ function testTableArrayFill(int index) { } } - assertEquality("[{\"id\":1, \"name\":\"John\", \"salary\":50000.0}]", ar[index].toString()); + assertEquality("[{\"id\":1,\"name\":\"John\",\"salary\":50000.0}]", ar[index].toString()); assertEquality("John", name.trim()); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/any/any-type-success.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/any/any-type-success.bal index 7d3900b08b32..5a5a8f095b28 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/any/any-type-success.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/any/any-type-success.bal @@ -10,12 +10,12 @@ function jsonReturnFunction() returns (json) { function tableReturnTestAsAny(){ any abc = tableReturnFunction(); - assertEquality("[{\"id\":1, \"name\":\"Jane\"},{\"id\":2, \"name\":\"Anne\"}]", abc.toString()); + assertEquality("[{\"id\":1,\"name\":\"Jane\"},{\"id\":2,\"name\":\"Anne\"}]", abc.toString()); } function inputAnyAsTableTest(){ table>? t = anyToTableFunction(tableReturnFunction()); - assertEquality("[{\"id\":1, \"name\":\"Jane\"},{\"id\":2, \"name\":\"Anne\"}]", t.toString()); + assertEquality("[{\"id\":1,\"name\":\"Jane\"},{\"id\":2,\"name\":\"Anne\"}]", t.toString()); } function anyToTableFunction (any aTable) returns (table>?) { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/anydata/anydata_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/anydata/anydata_test.bal index a226960cee41..94daa7536dc3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/anydata/anydata_test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/anydata/anydata_test.bal @@ -115,7 +115,7 @@ function testTableAssignment() { ]; anydata adt = t; - string employeeListAsString = "[{\"id\":1, \"name\":\"Mary\", \"salary\":300.5},{\"id\":2, \"name\":\"John\", \"salary\":200.5},{\"id\":3, \"name\":\"Jim\", \"salary\":330.5}]"; + string employeeListAsString = "[{\"id\":1,\"name\":\"Mary\",\"salary\":300.5},{\"id\":2,\"name\":\"John\",\"salary\":200.5},{\"id\":3,\"name\":\"Jim\",\"salary\":330.5}]"; assertEquality(employeeListAsString, adt.toString()); } @@ -206,7 +206,7 @@ function testConstrainedMaps(){ assertEquality(foo, adm["record"]); assertEquality(smap, adm["map"]); assertEquality(j, adm["json"]); - string employeeListAsString = "[{\"id\":1, \"name\":\"Mary\", \"salary\":300.5},{\"id\":2, \"name\":\"John\", \"salary\":200.5},{\"id\":3, \"name\":\"Jim\", \"salary\":330.5}]"; + string employeeListAsString = "[{\"id\":1,\"name\":\"Mary\",\"salary\":300.5},{\"id\":2,\"name\":\"John\",\"salary\":200.5},{\"id\":3,\"name\":\"Jim\",\"salary\":330.5}]"; assertEquality(employeeListAsString, adm["table"].toString()); } @@ -351,9 +351,9 @@ function testUnionAssignment2(){ i += 1; assertEquality("hello world!", rets[0].toString()); - string employeeListAsString = "[{\"id\":1, \"name\":\"Mary\", \"salary\":300.5},{\"id\":2, \"name\":\"John\", \"salary\":200.5},{\"id\":3, \"name\":\"Jim\", \"salary\":330.5}]"; + string employeeListAsString = "[{\"id\":1,\"name\":\"Mary\",\"salary\":300.5},{\"id\":2,\"name\":\"John\",\"salary\":200.5},{\"id\":3,\"name\":\"Jim\",\"salary\":330.5}]"; assertEquality(employeeListAsString, rets[1].toString()); - assertEquality("{\"name\":\"apple\", \"color\":\"red\", \"price\":40}", rets[2].toString()); + assertEquality("{\"name\":\"apple\",\"color\":\"red\",\"price\":40}", rets[2].toString()); assertEquality("The Lost World", rets[3].toString()); assertEquality(foo, rets[4]); assertEquality(cfoo, rets[5]); @@ -759,7 +759,7 @@ function testAnydataToTuple3() { ad = nt; if (ad is [[DataType[], string], int, float]) { - assertEquality("[{\"name\":\"apple\", \"color\":\"red\", \"price\":40},`The Lost World`] hello world!", ad[0].toString()); + assertEquality("[{\"name\":\"apple\",\"color\":\"red\",\"price\":40},`The Lost World`] hello world!", ad[0].toString()); } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/map-constraint-table-value.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/map-constraint-table-value.bal index aa922756be3f..515b4beb31dc 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/map-constraint-table-value.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/map-constraint-table-value.bal @@ -11,7 +11,7 @@ function testTableConstructExprWithAnyMap() { CustomerTable customerTable = table [{ id: 13 , name: "Sanjiva", lname: "Weerawarana" }, { id: 23 , name: "James" , lname: "Clark" }]; - assertEquality("[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\", \"lname\":\"Clark\"}]", customerTable.toString()); + assertEquality("[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\",\"lname\":\"Clark\"}]", customerTable.toString()); } type TableWithAnydata table>; @@ -21,7 +21,7 @@ function testTableConstructExprWithAnydataMap() { TableWithAnydata customerTable = table [{ id: 13 , name: "Sanjiva", lname: "Weerawarana" }, { id: 23 , name: "James" , lname: "Clark" }]; - assertEquality("[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\", \"lname\":\"Clark\"}]", customerTable.toString()); + assertEquality("[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\",\"lname\":\"Clark\"}]", customerTable.toString()); } type AssertionError distinct error; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-constraint-table-value.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-constraint-table-value.bal index 26620ea3a901..efa90c84b352 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-constraint-table-value.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-constraint-table-value.bal @@ -17,7 +17,7 @@ GlobalTable1 tab1 = table [ ]; function testGlobalTableConstructExpr() returns boolean { - return tab1.toString() == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"BBB\", \"age\":34}]"; + return tab1.toString() == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"BBB\",\"age\":34}]"; } function testTableMemberAccessStore() returns boolean { @@ -27,7 +27,7 @@ function testTableMemberAccessStore() returns boolean { ]; tab[{"CCC":"EEEE"}] = { m: {"CCC":"EEEE"}, age: 34 }; - return tab.toString() == "[{\"m\":{\"AAA\":\"DDDD\"}, \"age\":31},{\"m\":{\"BBB\":\"DDDD\"}, \"age\":34},{\"m\":{\"CCC\":\"EEEE\"}, \"age\":34}]"; + return tab.toString() == "[{\"m\":{\"AAA\":\"DDDD\"},\"age\":31},{\"m\":{\"BBB\":\"DDDD\"},\"age\":34},{\"m\":{\"CCC\":\"EEEE\"},\"age\":34}]"; } function testTableMemberAccessLoad() returns boolean { @@ -36,7 +36,7 @@ function testTableMemberAccessLoad() returns boolean { { m: {"BBB":"DDDD"}, age: 34 } ]; Foo aaa = tab[{"AAA":"DDDD"}]; - return aaa.toString() == "{\"m\":{\"AAA\":\"DDDD\"}, \"age\":31}"; + return aaa.toString() == "{\"m\":{\"AAA\":\"DDDD\"},\"age\":31}"; } type Customer record { @@ -45,7 +45,7 @@ type Customer record { string lname; }; -string cutomerListString = "[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\", \"lname\":\"Clark\"}]"; +string cutomerListString = "[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\",\"lname\":\"Clark\"}]"; type CustomerTableWithKS table key(id); @@ -151,7 +151,7 @@ function testKeylessTable() { { id: 23 , name: "James" , lname: "Clark" }]; assertEquality(3, customerTable.length()); - string expectedValues = "[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\", \"lname\":\"Clark\"},{\"id\":23, \"name\":\"James\", \"lname\":\"Clark\"}]"; + string expectedValues = "[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\",\"lname\":\"Clark\"},{\"id\":23,\"name\":\"James\",\"lname\":\"Clark\"}]"; assertEquality(expectedValues, customerTable.toString()); } @@ -194,7 +194,7 @@ function testTableWithKeySpecifier() { } function testInferTableType() { - string cutomerListString = "[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\"},{\"id\":133, \"name\":\"Mohan\", \"lname\":\"Darshan\", \"address\":\"Colombo\"}]"; + string cutomerListString = "[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\"},{\"id\":133,\"name\":\"Mohan\",\"lname\":\"Darshan\",\"address\":\"Colombo\"}]"; var tab = table [{ id: 13 , name: "Sanjiva", lname: "Weerawarana" }, { id: 23 , name: "James" }, { id: 133 , name: "Mohan", lname: "Darshan" , address: "Colombo"} ]; @@ -273,8 +273,8 @@ function testTableAsRecordField() { TableRec tableRecord2 = {detTable: tb}; - assertEquality("{\"detTable\":[{\"name\":\"Jo\", \"id\":\"azqw\"},{\"name\":\"Amy\", \"id\":\"ldhe\"}]}", tableRecord1.toString()); - assertEquality("{\"detTable\":[{\"name\":\"Jo\", \"id\":\"azqw\"},{\"name\":\"Amy\", \"id\":\"ldhe\"}]}", tableRecord2.toString()); + assertEquality("{\"detTable\":[{\"name\":\"Jo\",\"id\":\"azqw\"},{\"name\":\"Amy\",\"id\":\"ldhe\"}]}", tableRecord1.toString()); + assertEquality("{\"detTable\":[{\"name\":\"Jo\",\"id\":\"azqw\"},{\"name\":\"Amy\",\"id\":\"ldhe\"}]}", tableRecord2.toString()); } type Bar record {| diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-type-table-key.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-type-table-key.bal index 61e868efa70c..f50cf4769cb2 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-type-table-key.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/record-type-table-key.bal @@ -19,7 +19,7 @@ type Name record { }; type CustomerTableWithKS table key(name); -string tableAsString = "[{\"name\":{\"fname\":\"Sanjiva\", \"lname\":\"Weerawarana\"}, \"id\":13, \"address\":\"Sri Lanka\"},{\"name\":{\"fname\":\"James\", \"lname\":\"Clark\"}, \"id\":23, \"address\":\"Thailand\"}]"; +string tableAsString = "[{\"name\":{\"fname\":\"Sanjiva\",\"lname\":\"Weerawarana\"},\"id\":13,\"address\":\"Sri Lanka\"},{\"name\":{\"fname\":\"James\",\"lname\":\"Clark\"},\"id\":23,\"address\":\"Thailand\"}]"; function testTableTypeWithKeySpecifier() { CustomerTableWithKS tab = table [{name: {fname: "Sanjiva", lname: "Weerawarana"}, id: 13, address: "Sri Lanka" }, @@ -105,7 +105,7 @@ function testKeylessTable() { {name: {fname: "James" , lname: "Clark"}, id: 23 , address: "Thailand" }]; assertEquality(3, customerTable.length()); - string expectedValues = "[{\"name\":{\"fname\":\"Sanjiva\", \"lname\":\"Weerawarana\"}, \"id\":13, \"address\":\"Sri Lanka\"},{\"name\":{\"fname\":\"James\", \"lname\":\"Clark\"}, \"id\":23, \"address\":\"Thailand\"},{\"name\":{\"fname\":\"James\", \"lname\":\"Clark\"}, \"id\":23, \"address\":\"Thailand\"}]"; + string expectedValues = "[{\"name\":{\"fname\":\"Sanjiva\",\"lname\":\"Weerawarana\"},\"id\":13,\"address\":\"Sri Lanka\"},{\"name\":{\"fname\":\"James\",\"lname\":\"Clark\"},\"id\":23,\"address\":\"Thailand\"},{\"name\":{\"fname\":\"James\",\"lname\":\"Clark\"},\"id\":23,\"address\":\"Thailand\"}]"; assertEquality(expectedValues, customerTable.toString()); } @@ -147,7 +147,7 @@ function testTableWithKeySpecifier() { } function testInferTableType() { - string cutomerListString = "[{\"id\":13, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":23, \"name\":\"James\"},{\"id\":133, \"name\":\"Mohan\", \"lname\":\"Darshan\", \"address\":{\"no\":32, \"road\":\"High level\"}}]"; + string cutomerListString = "[{\"id\":13,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":23,\"name\":\"James\"},{\"id\":133,\"name\":\"Mohan\",\"lname\":\"Darshan\",\"address\":{\"no\":32,\"road\":\"High level\"}}]"; var tab = table [{ id: 13 , name: "Sanjiva", lname: "Weerawarana" }, { id: 23 , name: "James" }, { id: 133 , name: "Mohan", lname: "Darshan" , address: {no: 32, road: "High level"}}]; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/tables-as-func-arguments.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/tables-as-func-arguments.bal index 9e0860a045b6..66df63162faf 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/tables-as-func-arguments.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/tables-as-func-arguments.bal @@ -43,7 +43,7 @@ function testSameKeySpecifierInParamAndArg() returns boolean { { name: "CCC", age: 34 } ]; string str = getStringRepresentation1(tab1); - return str == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } function testKeySpecifierAndKeyConstraint() returns boolean { @@ -52,7 +52,7 @@ function testKeySpecifierAndKeyConstraint() returns boolean { { name: "CCC", age: 34 } ]; string str = getStringRepresentation2(tab1); - return str == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } function testSameKeyConstraintInArgAndParam() returns boolean { @@ -61,7 +61,7 @@ function testSameKeyConstraintInArgAndParam() returns boolean { { name: "CCC", age: 34 } ]; string str = getStringRepresentation2(tab1); - return str == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } function testNoKeyConstraintParam1() returns boolean { @@ -70,7 +70,7 @@ function testNoKeyConstraintParam1() returns boolean { { name: "CCC", age: 34 } ]; string str = getStringRepresentation3(tab1); - return str == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } function testNoKeyConstraintParam2() returns boolean { @@ -79,7 +79,7 @@ function testNoKeyConstraintParam2() returns boolean { { name: "CCC", age: 34 } ]; string str = getStringRepresentation3(tab1); - return str == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } function testUnionTypeInParam() returns boolean { @@ -94,7 +94,7 @@ function testUnionTypeInParam() returns boolean { ]; string str1 = getStringRepresentation4(tab1); string str2 = getStringRepresentation4(tab2); - return str1 == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]" && str2 == "[{\"id\":10, \"name\":\"Foo\", \"lname\":\"QWER\"},{\"id\":11, \"name\":\"Foo\", \"lname\":\"UYOR\"}]"; + return str1 == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]" && str2 == "[{\"id\":10,\"name\":\"Foo\",\"lname\":\"QWER\"},{\"id\":11,\"name\":\"Foo\",\"lname\":\"UYOR\"}]"; } function testUnionConstraintParam() returns boolean { @@ -109,7 +109,7 @@ function testUnionConstraintParam() returns boolean { ]; string str1 = getStringRepresentation5(tab1); string str2 = getStringRepresentation5(tab2); - return str1 == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]" && str2 == "[{\"id\":10, \"name\":\"Foo\", \"lname\":\"QWER\"},{\"id\":11, \"name\":\"Bar\", \"lname\":\"UYOR\"}]"; + return str1 == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]" && str2 == "[{\"id\":10,\"name\":\"Foo\",\"lname\":\"QWER\"},{\"id\":11,\"name\":\"Bar\",\"lname\":\"UYOR\"}]"; } function testUnionKeyConstraintParam() returns boolean { @@ -124,5 +124,5 @@ function testUnionKeyConstraintParam() returns boolean { ]; string str1 = getStringRepresentation6(tab1); string str2 = getStringRepresentation6(tab2); - return str1 == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]" && str2 == "[{\"name\":\"AAA\", \"age\":31},{\"name\":\"CCC\", \"age\":34}]"; + return str1 == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]" && str2 == "[{\"name\":\"AAA\",\"age\":31},{\"name\":\"CCC\",\"age\":34}]"; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/xml-type-table-key.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/xml-type-table-key.bal index 27e47cc562bf..3b38f7298fab 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/table/xml-type-table-key.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/table/xml-type-table-key.bal @@ -19,7 +19,7 @@ type Name record { type CustomerTableWithKS table key(id); type CustomerTableWithoutKS table; type CustomerTableWithKC table key; -string tableAsString = "[{\"id\":`123`, \"name\":{\"fname\":\"Sanjiva\", \"lname\":\"Weerawarana\"}, \"address\":\"Sri Lanka\"},{\"id\":`234`, \"name\":{\"fname\":\"James\", \"lname\":\"Clark\"}, \"address\":\"Thailand\"}]"; +string tableAsString = "[{\"id\":`123`,\"name\":{\"fname\":\"Sanjiva\",\"lname\":\"Weerawarana\"},\"address\":\"Sri Lanka\"},{\"id\":`234`,\"name\":{\"fname\":\"James\",\"lname\":\"Clark\"},\"address\":\"Thailand\"}]"; function testTableTypeWithXMLKeySpecifierV1() { CustomerTableWithKS tab = table [{id: xml `123`, name: {fname: "Sanjiva", lname: "Weerawarana"}, address: "Sri Lanka" }, @@ -116,7 +116,7 @@ function testTableWithKeySpecifier() { } function testInferTableType() { - string cutomerListString = "[{\"id\":`123`, \"name\":\"Sanjiva\", \"lname\":\"Weerawarana\"},{\"id\":`1233`, \"name\":\"James\"},{\"id\":`444`, \"name\":\"Mohan\", \"lname\":\"Darshan\", \"address\":{\"no\":32, \"road\":\"High level\"}}]"; + string cutomerListString = "[{\"id\":`123`,\"name\":\"Sanjiva\",\"lname\":\"Weerawarana\"},{\"id\":`1233`,\"name\":\"James\"},{\"id\":`444`,\"name\":\"Mohan\",\"lname\":\"Darshan\",\"address\":{\"no\":32,\"road\":\"High level\"}}]"; var tab = table [{ id: xml `123` , name: "Sanjiva", lname: "Weerawarana" }, { id: xml `1233` , name: "James" }, { id: xml `444` , name: "Mohan", lname: "Darshan" , address: {no: 32, road: "High level"}}]; From b30d3583800600b805fb6b6f4dbedae0dc6e1a58 Mon Sep 17 00:00:00 2001 From: gimantha Date: Sat, 12 Sep 2020 12:37:44 +0530 Subject: [PATCH 3/4] Fix tests --- .../main/java/org/ballerinalang/jvm/values/ErrorValue.java | 6 +++--- .../org/ballerinalang/langlib/test/LangLibValueTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/ErrorValue.java b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/ErrorValue.java index 68993e69f5a2..977eb4f449b6 100644 --- a/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/ErrorValue.java +++ b/bvm/ballerina-runtime/src/main/java/org/ballerinalang/jvm/values/ErrorValue.java @@ -89,13 +89,13 @@ public String stringValue(BLink parent) { private String getCauseToString(BLink parent) { if (cause != null) { - return ", " + cause.informalStringValue(parent); + return "," + cause.informalStringValue(parent); } return ""; } private String getDetailsToString(BLink parent) { - StringJoiner sj = new StringJoiner(", "); + StringJoiner sj = new StringJoiner(","); for (Object key : ((MapValue) details).getKeys()) { Object value = ((MapValue) details).get(key); if (value == null) { @@ -119,7 +119,7 @@ private String getDetailsToString(BLink parent) { } } } - return ", " + sj.toString(); + return "," + sj.toString(); } private String getModuleName() { diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java index 99a39369a4be..1bcced3831c0 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibValueTest.java @@ -141,7 +141,7 @@ public void testToString() { "Greatest HitsDolly Parton" + ""); Assert.assertEquals(array.getString(i++), "[\"str\",23,23.4,true]"); - Assert.assertEquals(array.getString(i++), "error FirstError (\"Reason1\", message=\"Test passing error " + + Assert.assertEquals(array.getString(i++), "error FirstError (\"Reason1\",message=\"Test passing error " + "union to a function\")"); Assert.assertEquals(array.getString(i++), "object Student"); Assert.assertEquals(array.getString(i++), "Rola from MMV"); @@ -163,7 +163,7 @@ public void testToString() { "Bonnie TylerGreatest Hits" + "Dolly Parton`," + "\"varArr\":[\"str\",23,23.4,true]," + - "\"varErr\":error FirstError (\"Reason1\", " + + "\"varErr\":error FirstError (\"Reason1\"," + "message=\"Test passing error union to a function\")," + "\"varObj\":object Student," + "\"varObj2\":Rola from MMV," + From 4ea2136a971b58af146559a9982107ff1ed3cd78 Mon Sep 17 00:00:00 2001 From: Mohan Date: Sat, 12 Sep 2020 13:09:46 +0530 Subject: [PATCH 4/4] Fix testcases according to the changes in spacing for map --- .../stdlib/services/dispatching/DataBindingTest.java | 6 +++--- .../test/javainterop/basic/InstanceMethodTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/http/src/test/java/org/ballerinalang/stdlib/services/dispatching/DataBindingTest.java b/stdlib/http/src/test/java/org/ballerinalang/stdlib/services/dispatching/DataBindingTest.java index b97818aa2059..eab12ae779e0 100644 --- a/stdlib/http/src/test/java/org/ballerinalang/stdlib/services/dispatching/DataBindingTest.java +++ b/stdlib/http/src/test/java/org/ballerinalang/stdlib/services/dispatching/DataBindingTest.java @@ -241,7 +241,7 @@ public void testDataBindingWithEmptyJsonPayload() { @Test(expectedExceptions = BallerinaConnectorException.class, expectedExceptionsMessageRegExp = "data binding failed: error\\(\"\\{ballerina/lang.typedesc\\}" + - "ConversionError\", message=\"'map' value cannot be converted to 'Person'.*") + "ConversionError\",message=\"'map' value cannot be converted to 'Person'.*") public void testDataBindingStructWithNoMatchingContent() { HTTPTestRequest requestMsg = MessageUtils .generateHTTPMessage("/echo/body6", "POST", "{'name':'WSO2', 'team':8}"); @@ -251,7 +251,7 @@ public void testDataBindingStructWithNoMatchingContent() { @Test(expectedExceptions = BallerinaConnectorException.class, expectedExceptionsMessageRegExp = "data binding failed: error\\(\"\\{ballerina/lang.typedesc\\}" + - "ConversionError\", message=\"'map' value cannot be converted to 'Stock'.*") + "ConversionError\",message=\"'map' value cannot be converted to 'Stock'.*") public void testDataBindingStructWithInvalidTypes() { HTTPTestRequest requestMsg = MessageUtils .generateHTTPMessage("/echo/body7", "POST", "{'name':'WSO2', 'team':8}"); @@ -261,7 +261,7 @@ public void testDataBindingStructWithInvalidTypes() { @Test(expectedExceptions = BallerinaConnectorException.class, expectedExceptionsMessageRegExp = ".*data binding failed: error\\(\"\\{ballerina/lang" + - ".typedesc\\}ConversionError\", message=\"'json\\[\\]' value cannot be converted to 'Person\\[\\]'.*") + ".typedesc\\}ConversionError\",message=\"'json\\[\\]' value cannot be converted to 'Person\\[\\]'.*") public void testDataBindingWithRecordArrayNegative() { HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/body8", "POST", "[{'name':'wso2','team':12}, " + "{'lang':'ballerina','age':3}]"); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/InstanceMethodTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/InstanceMethodTest.java index 07f0e3936a74..28375f0aeb5a 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/InstanceMethodTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/javainterop/basic/InstanceMethodTest.java @@ -245,7 +245,7 @@ public void testUncheckedErrorDetail() { } catch (Throwable e) { Assert.assertTrue(e.getMessage().contains("error: java.lang.RuntimeException")); Assert.assertTrue(e.getMessage().contains("{\"message\":\"Unchecked Exception")); - Assert.assertTrue(e.getMessage().contains("\"cause\":error(\"java.lang.Throwable\", " + + Assert.assertTrue(e.getMessage().contains("\"cause\":error(\"java.lang.Throwable\"," + "message=\"Unchecked cause\"")); } }