Skip to content

Commit

Permalink
Merge pull request #16 from gimantha/toString-cycles
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
mohanvive committed Sep 12, 2020
2 parents 2a583d0 + dae58ea commit 3fccb04
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public Object frozenCopy(Map<Object, Object> refs) {

@Override
public String stringValue(BLink parent) {
StringJoiner sj = new StringJoiner(", ");
StringJoiner sj = new StringJoiner(",");
for (Map.Entry<K, V> kvEntry : this.entrySet()) {
K key = kvEntry.getKey();
V value = kvEntry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++),
"<CATALOG>" +
"<CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST></CD>" +
Expand All @@ -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\":`<CATALOG><CD><TITLE>Empire Burlesque</TITLE>" +
"<ARTIST>Bob Dylan</ARTIST></CD><CD><TITLE>Hide your heart</TITLE>" +
"<ARTIST>Bonnie Tyler</ARTIST></CD><CD><TITLE>Greatest Hits</TITLE>" +
"<ARTIST>Dolly Parton</ARTIST></CD></CATALOG>`, " +
"\"varArr\":[\"str\",23,23.4,true], " +
"<ARTIST>Dolly Parton</ARTIST></CD></CATALOG>`," +
"\"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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ 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
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
Expand Down

0 comments on commit 3fccb04

Please sign in to comment.