From 91d9a3d02fb92e5b25b8893c860228fc74d9dc2c Mon Sep 17 00:00:00 2001 From: SasinduDilshara Date: Fri, 9 Aug 2024 03:25:46 +0530 Subject: [PATCH] Rename parse list api --- README.md | 2 +- .../tests/constraint_validation_test.bal | 10 +- .../tests/parse_list_type_as_list_test.bal | 202 ++++++------ .../tests/parse_list_type_as_record_test.bal | 290 +++++++++--------- .../tests/parse_record_type_as_list_test.bal | 4 +- .../tests/parse_type_compatibility_test.bal | 28 +- .../tests/test_union_types_with_headers.bal | 88 +++--- .../tests/test_with_intersection_types.bal | 22 +- .../tests/test_with_singleton_test.bal | 12 +- .../tests/test_with_union_types.bal | 114 +++---- .../tests/user_config_projection_tests.bal | 50 +-- .../user_config_with_parser_options_test.bal | 42 +-- ballerina/Package.md | 2 +- ballerina/csv_api.bal | 10 +- ballerina/types.bal | 5 +- .../sample_package_1/main.bal | 32 +- .../sample_package_4/main.bal | 8 +- .../sample_package_6/main.bal | 8 +- .../lib/data/csvdata/compiler/Constants.java | 2 +- .../lib/data/csvdata/csv/Native.java | 4 +- 20 files changed, 468 insertions(+), 467 deletions(-) diff --git a/README.md b/README.md index 08f9f82..181d189 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ type Book record { public function main() returns error? { string[][] bookArray = [["Clean Code","2008"],["Clean Architecture","2017"]]; - Book[] author = check csv:parseLists(bookArray, customHeaders = ["name", "year"]); + Book[] author = check csv:parseList(bookArray, customHeaders = ["name", "year"]); io:println(author); } ``` diff --git a/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal b/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal index c1266b6..de74848 100644 --- a/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal +++ b/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal @@ -67,10 +67,10 @@ function testConstraintWithLists() returns error? { test:assertTrue((cList1).message().startsWith("Validation failed") && (cList1).message().includes("length")); - cList1 = csv:parseLists([["1"], ["2"], ["3"], ["4"]], {customHeaders: ["a", "b", "c", "d"]}); + cList1 = csv:parseList([["1"], ["2"], ["3"], ["4"]], {customHeaders: ["a", "b", "c", "d"]}); test:assertEquals(cList1, [[1], [2], [3], [4]]); - cList1 = csv:parseLists([["1"], ["2"], ["3"], ["4"], ["5"], ["6"]], {customHeaders: ["a", "b", "c", "d"]}); + cList1 = csv:parseList([["1"], ["2"], ["3"], ["4"], ["5"], ["6"]], {customHeaders: ["a", "b", "c", "d"]}); test:assertTrue(cList1 is csv:Error); test:assertTrue((cList1).message().startsWith("Validation failed") && (cList1).message().includes("length")); @@ -115,15 +115,15 @@ function testConstraintWithRecords() returns error? { test:assertTrue((cRec1).message().startsWith("Validation failed") && (cRec1).message().includes("minLength")); - cRec1 = csv:parseLists([["4", "abc"], ["3", "cde"]], {customHeaders: ["a", "b"]}); + cRec1 = csv:parseList([["4", "abc"], ["3", "cde"]], {customHeaders: ["a", "b"]}); test:assertEquals(cRec1, [{a: 4, b: "abc"}, {a: 3, b: "cde"}]); - cRec1 = csv:parseLists([["4", "abc"], ["11", "cde"]], {customHeaders: ["a", "b"]}); + cRec1 = csv:parseList([["4", "abc"], ["11", "cde"]], {customHeaders: ["a", "b"]}); test:assertTrue(cRec1 is csv:Error); test:assertTrue((cRec1).message().startsWith("Validation failed") && (cRec1).message().includes("maxValue")); - cRec1 = csv:parseLists([["4", "abc"], ["5", "b"]], {customHeaders: ["a", "b"]}); + cRec1 = csv:parseList([["4", "abc"], ["5", "b"]], {customHeaders: ["a", "b"]}); test:assertTrue(cRec1 is csv:Error); test:assertTrue((cRec1).message().startsWith("Validation failed") && (cRec1).message().includes("minLength")); diff --git a/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_list_test.bal b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_list_test.bal index 8a1a61a..1bd498c 100644 --- a/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_list_test.bal +++ b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_list_test.bal @@ -20,73 +20,73 @@ import ballerina/test; @test:Config function testFromCsvWithTypeForTupleAndTupleAsExpectedType() { - StringTuple1Array|csv:Error st1st1 = csv:parseLists([st1, st1], {}, StringTuple1Array); + StringTuple1Array|csv:Error st1st1 = csv:parseList([st1, st1], {}, StringTuple1Array); test:assertEquals(st1st1, [ [s1, s2, "", ""], [s1, s2, "", ""] ]); - StringTuple1Array|csv:Error st2st1 = csv:parseLists([st2, st2], {}, StringTuple1Array); + StringTuple1Array|csv:Error st2st1 = csv:parseList([st2, st2], {}, StringTuple1Array); test:assertEquals(st2st1, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringTuple1Array|csv:Error st3st1 = csv:parseLists([st3, st3], {}, StringTuple1Array); + StringTuple1Array|csv:Error st3st1 = csv:parseList([st3, st3], {}, StringTuple1Array); test:assertEquals(st3st1, [ [s1, s2, "", ""], [s1, s2, "", ""] ]); - StringTuple1Array|csv:Error st4st1 = csv:parseLists([st4, st4], {}, StringTuple1Array); + StringTuple1Array|csv:Error st4st1 = csv:parseList([st4, st4], {}, StringTuple1Array); test:assertEquals(st4st1, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringTuple2Array|csv:Error st1st2 = csv:parseLists([st1, st1], {}, StringTuple2Array); + StringTuple2Array|csv:Error st1st2 = csv:parseList([st1, st1], {}, StringTuple2Array); test:assertEquals(st1st2, [ [s1, s2], [s1, s2] ]); - StringTuple2Array|csv:Error st2st2 = csv:parseLists([st2, st2], {}, StringTuple2Array); + StringTuple2Array|csv:Error st2st2 = csv:parseList([st2, st2], {}, StringTuple2Array); test:assertEquals(st2st2, [ [s1, s2], [s1, s2] ]); - StringTuple2Array|csv:Error st3st2 = csv:parseLists([st3, st3], {}, StringTuple2Array); + StringTuple2Array|csv:Error st3st2 = csv:parseList([st3, st3], {}, StringTuple2Array); test:assertEquals(st3st2, [ [s1, s2], [s1, s2] ]); - StringTuple2Array|csv:Error st4st2 = csv:parseLists([st4, st4], {}, StringTuple2Array); + StringTuple2Array|csv:Error st4st2 = csv:parseList([st4, st4], {}, StringTuple2Array); test:assertEquals(st4st2, [ [s1, s2], [s1, s2] ]); - StringTuple3Array|csv:Error st1st3 = csv:parseLists([st1, st1], {}, StringTuple3Array); + StringTuple3Array|csv:Error st1st3 = csv:parseList([st1, st1], {}, StringTuple3Array); test:assertEquals(st1st3, [ [s1, s2], [s1, s2] ]); - StringTuple3Array|csv:Error st2st3 = csv:parseLists([st2, st2], {}, StringTuple3Array); + StringTuple3Array|csv:Error st2st3 = csv:parseList([st2, st2], {}, StringTuple3Array); test:assertEquals(st2st3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringTuple3Array|csv:Error st3st3 = csv:parseLists([st3, st3], {}, StringTuple3Array); + StringTuple3Array|csv:Error st3st3 = csv:parseList([st3, st3], {}, StringTuple3Array); test:assertEquals(st3st3, [ [s1, s2], [s1, s2] ]); - StringTuple3Array|csv:Error st4st3 = csv:parseLists([st4, st4], {}, StringTuple3Array); + StringTuple3Array|csv:Error st4st3 = csv:parseList([st4, st4], {}, StringTuple3Array); test:assertEquals(st4st3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] @@ -95,179 +95,179 @@ function testFromCsvWithTypeForTupleAndTupleAsExpectedType() { @test:Config function testFromCsvWithTypeForTupleAndTupleAsExpectedType2() { - StringTuple4Array|csv:Error st1st4 = csv:parseLists([st1, st1], {}, StringTuple4Array); + StringTuple4Array|csv:Error st1st4 = csv:parseList([st1, st1], {}, StringTuple4Array); test:assertEquals(st1st4, [ [s1, s2], [s1, s2] ]); - StringTuple4Array|csv:Error st2st4 = csv:parseLists([st2, st2], {}, StringTuple4Array); + StringTuple4Array|csv:Error st2st4 = csv:parseList([st2, st2], {}, StringTuple4Array); test:assertEquals(st2st4, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringTuple4Array|csv:Error st3st4 = csv:parseLists([st3, st3], {}, StringTuple4Array); + StringTuple4Array|csv:Error st3st4 = csv:parseList([st3, st3], {}, StringTuple4Array); test:assertEquals(st3st4, [ [s1, s2], [s1, s2] ]); - StringTuple4Array|csv:Error st4st4 = csv:parseLists([st4, st4], {}, StringTuple4Array); + StringTuple4Array|csv:Error st4st4 = csv:parseList([st4, st4], {}, StringTuple4Array); test:assertEquals(st4st4, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - AnydataTuple3Array|csv:Error st1anydt3 = csv:parseLists([st1, st1], {}, AnydataTuple3Array); + AnydataTuple3Array|csv:Error st1anydt3 = csv:parseList([st1, st1], {}, AnydataTuple3Array); test:assertEquals(st1anydt3, [ [s1, s2], [s1, s2] ]); - AnydataTuple3Array|csv:Error st2anydt3 = csv:parseLists([st2, st2], {}, AnydataTuple3Array); + AnydataTuple3Array|csv:Error st2anydt3 = csv:parseList([st2, st2], {}, AnydataTuple3Array); test:assertEquals(st2anydt3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - AnydataTuple3Array|csv:Error st3anydt3 = csv:parseLists([st3, st3], {}, AnydataTuple3Array); + AnydataTuple3Array|csv:Error st3anydt3 = csv:parseList([st3, st3], {}, AnydataTuple3Array); test:assertEquals(st3anydt3, [ [s1, s2], [s1, s2] ]); - AnydataTuple3Array|csv:Error st4anydt3 = csv:parseLists([st4, st4], {}, AnydataTuple3Array); + AnydataTuple3Array|csv:Error st4anydt3 = csv:parseList([st4, st4], {}, AnydataTuple3Array); test:assertEquals(st4anydt3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - JsonTuple3Array|csv:Error st1jt3 = csv:parseLists([st1, st1], {}, JsonTuple3Array); + JsonTuple3Array|csv:Error st1jt3 = csv:parseList([st1, st1], {}, JsonTuple3Array); test:assertEquals(st1jt3, [ [s1, s2], [s1, s2] ]); - JsonTuple3Array|csv:Error st2jt3 = csv:parseLists([st2, st2], {}, JsonTuple3Array); + JsonTuple3Array|csv:Error st2jt3 = csv:parseList([st2, st2], {}, JsonTuple3Array); test:assertEquals(st2jt3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - JsonTuple3Array|csv:Error st3jt3 = csv:parseLists([st3, st3], {}, JsonTuple3Array); + JsonTuple3Array|csv:Error st3jt3 = csv:parseList([st3, st3], {}, JsonTuple3Array); test:assertEquals(st3jt3, [ [s1, s2], [s1, s2] ]); - JsonTuple3Array|csv:Error st4jt3 = csv:parseLists([st4, st4], {}, JsonTuple3Array); + JsonTuple3Array|csv:Error st4jt3 = csv:parseList([st4, st4], {}, JsonTuple3Array); test:assertEquals(st4jt3, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - DecimalTuple4Array|csv:Error st1dta = csv:parseLists([st1, st1], {}, DecimalTuple4Array); + DecimalTuple4Array|csv:Error st1dta = csv:parseList([st1, st1], {}, DecimalTuple4Array); test:assertTrue(st1dta is csv:Error); test:assertEquals((st1dta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal")); - IntegerTuple3Array|csv:Error st2bta = csv:parseLists([st2, st2], {}, IntegerTuple3Array); + IntegerTuple3Array|csv:Error st2bta = csv:parseList([st2, st2], {}, IntegerTuple3Array); test:assertTrue(st2bta is csv:Error); test:assertEquals((st2bta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "int")); - NilTuple3Array|csv:Error st3nta = csv:parseLists([st3, st3], {}, NilTuple3Array); + NilTuple3Array|csv:Error st3nta = csv:parseList([st3, st3], {}, NilTuple3Array); test:assertTrue(st3nta is csv:Error); test:assertEquals((st3nta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "()")); - BooleanTuple4Array|csv:Error st4bta = csv:parseLists([st4, st4], {}, BooleanTuple4Array); + BooleanTuple4Array|csv:Error st4bta = csv:parseList([st4, st4], {}, BooleanTuple4Array); test:assertTrue(st4bta is csv:Error); test:assertEquals((st4bta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "boolean")); } @test:Config function testFromCsvWithTypeForTupleAndTupleAsExpectedType3() { - [string, boolean, int][]|csv:Error ct1bt4 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {}); + [string, boolean, int][]|csv:Error ct1bt4 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {}); test:assertEquals(ct1bt4, [ ["a", true, 1], ["a", true, 1] ]); - [(), float, decimal, boolean, int, string][]|csv:Error ct1bt6 = csv:parseLists( + [(), float, decimal, boolean, int, string][]|csv:Error ct1bt6 = csv:parseList( [["null", "2.23", "0", "true", "1", "a"], ["null", "0", "2.23", "true", "1", "a"]]); test:assertEquals(ct1bt6, [ [(), 2.23, 0, true, 1, "a"], [(), 0, 2.23, true, 1, "a"] ]); - [decimal, boolean, int, string][]|csv:Error ct1bt7 = csv:parseLists( + [decimal, boolean, int, string][]|csv:Error ct1bt7 = csv:parseList( [["0", "true", "1", "a"], ["2.23", "true", "1", "a"]]); test:assertEquals(ct1bt7, [ [0, true, 1, "a"], [2.23, true, 1, "a"] ]); - [decimal, boolean, int, string, anydata...][]|csv:Error ct1bt8 = csv:parseLists( + [decimal, boolean, int, string, anydata...][]|csv:Error ct1bt8 = csv:parseList( [["0", "true", "1", "a", "null", "2.23"], ["2.23", "true", "1", "a", "null", "0"]]); test:assertEquals(ct1bt8, [ [0, true, 1, "a", (), 2.23], [2.23, true, 1, "a", (), 0] ]); - [(), float, decimal, boolean, int, string, string...][]|csv:Error ct1bt9 = csv:parseLists( + [(), float, decimal, boolean, int, string, string...][]|csv:Error ct1bt9 = csv:parseList( [["null", "2.23", "0", "true", "1", "a"], ["null", "0", "2.23", "true", "1", "a"]]); test:assertEquals(ct1bt9, [ [(), 2.23, 0, true, 1, "a"], [(), 0, 2.23, true, 1, "a"] ]); - [decimal, boolean, int, string, string...][]|csv:Error ct1bt10 = csv:parseLists( + [decimal, boolean, int, string, string...][]|csv:Error ct1bt10 = csv:parseList( [["0", "true", "1", "a", "null", "2.23"], ["2.23", "true", "1", "a", "null", "0"]]); test:assertEquals(ct1bt10, [ [0, true, 1, "a", "null", "2.23"], [2.23, true, 1, "a", "null", "0"] ]); - [decimal, boolean, int, string, ()...][]|csv:Error ct1bt11 = csv:parseLists( + [decimal, boolean, int, string, ()...][]|csv:Error ct1bt11 = csv:parseList( [["null", "2.23", "0", "true", "1", "a"], ["null", "0", "2.23", "true", "1", "a"]]); test:assertTrue(ct1bt11 is csv:Error); //TODO: Fix the message test:assertEquals((ct1bt11).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "decimal")); - [(), decimal, float, boolean, ()...][]|csv:Error ct1bt11_2 = csv:parseLists( + [(), decimal, float, boolean, ()...][]|csv:Error ct1bt11_2 = csv:parseList( [["null", "2.23", "0", "true", "1", "a"], ["null", "0", "2.23", "true", "1", "a"]]); test:assertTrue(ct1bt11_2 is csv:Error); test:assertEquals((ct1bt11_2).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "4", "()")); - [()...][]|csv:Error ct1bt12 = csv:parseLists( + [()...][]|csv:Error ct1bt12 = csv:parseList( [["null", "2.23", "0", "true", "1", "a"], ["null", "0", "2.23", "true", "1", "a"]]); test:assertTrue(ct1bt12 is csv:Error); test:assertEquals((ct1bt12).message(), common:generateErrorMessageForInvalidValueForArrayType("2.23", "1", "()")); - [string...][]|csv:Error ct1bt13 = csv:parseLists( + [string...][]|csv:Error ct1bt13 = csv:parseList( [["1", "a"], ["1", "a"]]); test:assertEquals(ct1bt13, [ ["1", "a"], ["1", "a"] ]); - [boolean...][]|csv:Error ct1bt14 = csv:parseLists( + [boolean...][]|csv:Error ct1bt14 = csv:parseList( [["2.23", "null"], ["7", "()"]]); test:assertTrue(ct1bt14 is csv:Error); test:assertEquals((ct1bt14).message(), common:generateErrorMessageForInvalidValueForArrayType("2.23", "0", "boolean")); - int?[][]|csv:Error ct1bt15 = csv:parseLists( + int?[][]|csv:Error ct1bt15 = csv:parseList( [["1", "()"], ["1", "2"]]); test:assertEquals(ct1bt15, [ [1, ()], [1, 2] ]); - int[][]|csv:Error ct1bt16 = csv:parseLists( + int[][]|csv:Error ct1bt16 = csv:parseList( [["1", "2"], ["1", "()"]]); test:assertTrue(ct1bt16 is csv:Error); test:assertEquals((ct1bt16).message(), common:generateErrorMessageForInvalidValueForArrayType("()", "1", "int")); - int[][]|csv:Error ct1bt17 = csv:parseLists( + int[][]|csv:Error ct1bt17 = csv:parseList( [["a", "b"], ["a", "b"]]); test:assertTrue(ct1bt17 is csv:Error); test:assertEquals((ct1bt17).message(), common:generateErrorMessageForInvalidValueForArrayType("a", "0", "int")); @@ -275,55 +275,55 @@ function testFromCsvWithTypeForTupleAndTupleAsExpectedType3() { @test:Config function testFromCsvWithTypeForTupleAndArrayAsExpectedType() { - StringArrayArray|csv:Error st1saa = csv:parseLists([st1, st1], {}, StringArrayArray); + StringArrayArray|csv:Error st1saa = csv:parseList([st1, st1], {}, StringArrayArray); test:assertEquals(st1saa, [ [s1, s2], [s1, s2] ]); - StringArrayArray|csv:Error st2saa = csv:parseLists([st2, st2], {}, StringArrayArray); + StringArrayArray|csv:Error st2saa = csv:parseList([st2, st2], {}, StringArrayArray); test:assertEquals(st2saa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringArrayArray|csv:Error st3saa = csv:parseLists([st3, st3], {}, StringArrayArray); + StringArrayArray|csv:Error st3saa = csv:parseList([st3, st3], {}, StringArrayArray); test:assertEquals(st3saa, [ [s1, s2], [s1, s2] ]); - StringArrayArray|csv:Error st4saa = csv:parseLists([st4, st4], {}, StringArrayArray); + StringArrayArray|csv:Error st4saa = csv:parseList([st4, st4], {}, StringArrayArray); test:assertEquals(st4saa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - NillableStringArrayArray|csv:Error st1nsaa = csv:parseLists([st1, st1], {}, NillableStringArrayArray); + NillableStringArrayArray|csv:Error st1nsaa = csv:parseList([st1, st1], {}, NillableStringArrayArray); test:assertEquals(st1nsaa, [ [s1, s2], [s1, s2] ]); - NillableStringArrayArray|csv:Error st2nsaa = csv:parseLists([st2, st2], {}, NillableStringArrayArray); + NillableStringArrayArray|csv:Error st2nsaa = csv:parseList([st2, st2], {}, NillableStringArrayArray); test:assertEquals(st2nsaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - NillableStringArrayArray|csv:Error st3nsaa = csv:parseLists([st3, st3], {}, NillableStringArrayArray); + NillableStringArrayArray|csv:Error st3nsaa = csv:parseList([st3, st3], {}, NillableStringArrayArray); test:assertEquals(st3nsaa, [ [s1, s2], [s1, s2] ]); - NillableStringArrayArray|csv:Error st4nsaa = csv:parseLists([st4, st4], {}, NillableStringArrayArray); + NillableStringArrayArray|csv:Error st4nsaa = csv:parseList([st4, st4], {}, NillableStringArrayArray); test:assertEquals(st4nsaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - NillableIntOrUnionStringArrayArray|csv:Error st1nsuiaa = csv:parseLists([st1, st1], {}, NillableIntOrUnionStringArrayArray); + NillableIntOrUnionStringArrayArray|csv:Error st1nsuiaa = csv:parseList([st1, st1], {}, NillableIntOrUnionStringArrayArray); test:assertEquals(st1nsuiaa, [ [s1, s2], [s1, s2] @@ -332,101 +332,101 @@ function testFromCsvWithTypeForTupleAndArrayAsExpectedType() { @test:Config function testFromCsvWithTypeForTupleAndTupleAsExpectedType4() { - NillableIntOrUnionStringArrayArray|csv:Error st2nsuiaa = csv:parseLists([st2, st2], {}, NillableIntOrUnionStringArrayArray); + NillableIntOrUnionStringArrayArray|csv:Error st2nsuiaa = csv:parseList([st2, st2], {}, NillableIntOrUnionStringArrayArray); test:assertEquals(st2nsuiaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - NillableIntOrUnionStringArrayArray|csv:Error st3nsuiaa = csv:parseLists([st3, st3], {}, NillableIntOrUnionStringArrayArray); + NillableIntOrUnionStringArrayArray|csv:Error st3nsuiaa = csv:parseList([st3, st3], {}, NillableIntOrUnionStringArrayArray); test:assertEquals(st3nsuiaa, [ [s1, s2], [s1, s2] ]); - NillableIntOrUnionStringArrayArray|csv:Error st4nsuiaa = csv:parseLists([st4, st4], {}, NillableIntOrUnionStringArrayArray); + NillableIntOrUnionStringArrayArray|csv:Error st4nsuiaa = csv:parseList([st4, st4], {}, NillableIntOrUnionStringArrayArray); test:assertEquals(st4nsuiaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - StringArray2Array|csv:Error st1saa2 = csv:parseLists([st1, st1], {}, StringArray2Array); + StringArray2Array|csv:Error st1saa2 = csv:parseList([st1, st1], {}, StringArray2Array); test:assertEquals(st1saa2, [ [s1, s2], [s1, s2] ]); - StringArray2Array|csv:Error st2saa2 = csv:parseLists([st2, st2], {}, StringArray2Array); + StringArray2Array|csv:Error st2saa2 = csv:parseList([st2, st2], {}, StringArray2Array); test:assertEquals(st2saa2, [ [s1, s2], [s1, s2] ]); - StringArray2Array|csv:Error st3saa2 = csv:parseLists([st3, st3], {}, StringArray2Array); + StringArray2Array|csv:Error st3saa2 = csv:parseList([st3, st3], {}, StringArray2Array); test:assertEquals(st3saa2, [ [s1, s2], [s1, s2] ]); - StringArray2Array|csv:Error st4saa2 = csv:parseLists([st4, st4], {}, StringArray2Array); + StringArray2Array|csv:Error st4saa2 = csv:parseList([st4, st4], {}, StringArray2Array); test:assertEquals(st4saa2, [ [s1, s2], [s1, s2] ]); - JsonArray1Array|csv:Error st1jaa = csv:parseLists([st1, st1], {}, JsonArray1Array); + JsonArray1Array|csv:Error st1jaa = csv:parseList([st1, st1], {}, JsonArray1Array); test:assertEquals(st1jaa, [ [s1, s2], [s1, s2] ]); - JsonArray1Array|csv:Error st2jaa = csv:parseLists([st2, st2], {}, JsonArray1Array); + JsonArray1Array|csv:Error st2jaa = csv:parseList([st2, st2], {}, JsonArray1Array); test:assertEquals(st2jaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - JsonArray1Array|csv:Error st3jaa = csv:parseLists([st3, st3], {}, JsonArray1Array); + JsonArray1Array|csv:Error st3jaa = csv:parseList([st3, st3], {}, JsonArray1Array); test:assertEquals(st3jaa, [ [s1, s2], [s1, s2] ]); - JsonArray1Array|csv:Error st4jaa = csv:parseLists([st4, st4], {}, JsonArray1Array); + JsonArray1Array|csv:Error st4jaa = csv:parseList([st4, st4], {}, JsonArray1Array); test:assertEquals(st4jaa, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - AnydataArray1Array|csv:Error st1anyda = csv:parseLists([st1, st1], {}, AnydataArray1Array); + AnydataArray1Array|csv:Error st1anyda = csv:parseList([st1, st1], {}, AnydataArray1Array); test:assertEquals(st1anyda, [ [s1, s2], [s1, s2] ]); - AnydataArray1Array|csv:Error st2anyda = csv:parseLists([st2, st2], {}, AnydataArray1Array); + AnydataArray1Array|csv:Error st2anyda = csv:parseList([st2, st2], {}, AnydataArray1Array); test:assertEquals(st2anyda, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - AnydataArray1Array|csv:Error st3anyda = csv:parseLists([st3, st3], {}, AnydataArray1Array); + AnydataArray1Array|csv:Error st3anyda = csv:parseList([st3, st3], {}, AnydataArray1Array); test:assertEquals(st3anyda, [ [s1, s2], [s1, s2] ]); - AnydataArray1Array|csv:Error st4anyda = csv:parseLists([st4, st4], {}, AnydataArray1Array); + AnydataArray1Array|csv:Error st4anyda = csv:parseList([st4, st4], {}, AnydataArray1Array); test:assertEquals(st4anyda, [ [s1, s2, s3, s2], [s1, s2, s3, s2] ]); - DecimalArray1Array|csv:Error st1dda = csv:parseLists([st1, st1], {}, DecimalArray1Array); + DecimalArray1Array|csv:Error st1dda = csv:parseList([st1, st1], {}, DecimalArray1Array); test:assertTrue(st1dda is csv:Error); test:assertEquals((st1dda).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal")); - DecimalArray1Array|csv:Error st3dda = csv:parseLists([st3, st3], {}, DecimalArray1Array); + DecimalArray1Array|csv:Error st3dda = csv:parseList([st3, st3], {}, DecimalArray1Array); test:assertTrue(st3dda is csv:Error); test:assertEquals((st3dda).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal")); } @@ -435,13 +435,13 @@ function testFromCsvWithTypeForTupleAndTupleAsExpectedType4() { function testArrayIndexes() { string[][] csv = [["1", "2", "3"], ["3", "4", "5"], ["5", "6", "7"], ["7", "8", "9"]]; - [int, int][2]|csv:Error rec3_2 = csv:parseLists(csv); + [int, int][2]|csv:Error rec3_2 = csv:parseList(csv); test:assertEquals(rec3_2, [ [1, 2], [3, 4] ]); - int[2][]|csv:Error rec5 = csv:parseLists(csv); + int[2][]|csv:Error rec5 = csv:parseList(csv); test:assertEquals(rec5, [ [1, 2, 3], [3, 4, 5] @@ -450,160 +450,160 @@ function testArrayIndexes() { @test:Config function testParseListsWithOutputHeaders() { - [string, boolean, int][]|csv:Error ct1bt1 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1}); + [string, boolean, int][]|csv:Error ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1}); test:assertEquals(ct1bt1, [ ["a", true, 1] ]); - ct1bt1 = csv:parseLists([["a", "b", "c"], ["a", "b", "c"]], {headerRows: 2}); + ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headerRows: 2}); test:assertEquals(ct1bt1, []); - ct1bt1 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"]}); + ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"]}); test:assertEquals(ct1bt1, [ ["a", true, 1] ]); - ct1bt1 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"]}); + ct1bt1 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"]}); test:assertEquals(ct1bt1, [ ["a", true, 1], ["a", true, 1] ]); - ct1bt1 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21}); + ct1bt1 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21}); test:assertEquals(ct1bt1, []); - (string|boolean|int)[][]|csv:Error ct1bt1_2 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1}); + (string|boolean|int)[][]|csv:Error ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1}); test:assertEquals(ct1bt1_2, [ ["a", true, 1] ]); - ct1bt1_2 = csv:parseLists([["a", "b", "c"], ["a", "b", "c"]], {headerRows: 2}); + ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headerRows: 2}); test:assertEquals(ct1bt1_2, []); - ct1bt1_2 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"]}); + ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"]}); test:assertEquals(ct1bt1_2, [ ["a", true, 1] ]); - ct1bt1_2 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"]}); + ct1bt1_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"]}); test:assertEquals(ct1bt1_2, [ ["a", true, 1], ["a", true, 1] ]); - ct1bt1_2 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21}); + ct1bt1_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21}); test:assertEquals(ct1bt1_2, []); - [string, boolean, int][]|csv:Error ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); + [string, boolean, int][]|csv:Error ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct1bt1_3, [ ["a", true, 1], ["a", true, 1] ]); - ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, outputWithHeaders: true}); + ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, outputWithHeaders: true}); test:assertTrue(ct1bt1_3 is csv:Error); test:assertEquals((ct1bt1_3).message(), "Custom headers should be provided"); - ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, outputWithHeaders: true}); + ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, outputWithHeaders: true}); test:assertTrue(ct1bt1_3 is csv:Error); test:assertEquals((ct1bt1_3).message(), "Custom headers should be provided"); - ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertTrue(ct1bt1_3 is csv:Error); test:assertEquals((ct1bt1_3).message(), common:generateErrorMessageForInvalidValueForArrayType("h2", "1", "boolean")); - ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertTrue(ct1bt1_3 is csv:Error); test:assertEquals((ct1bt1_3).message(), common:generateErrorMessageForInvalidValueForArrayType("h2", "1", "boolean")); - ct1bt1_3 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21, outputWithHeaders: true}); + ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21, outputWithHeaders: true}); test:assertEquals(ct1bt1_3, []); - string[][]|csv:Error ct1bt1_4 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); + string[][]|csv:Error ct1bt1_4 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct1bt1_4, [ ["a", "b", "c"], ["a", "true", "1"] ]); - ct1bt1_4 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt1_4 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_4, [ ["h1", "h2", "h3"], ["a", "true", "1"], ["a", "true", "1"] ]); - (int|boolean|string)[][]|csv:Error ct1bt1_4_2 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); + (int|boolean|string)[][]|csv:Error ct1bt1_4_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct1bt1_4_2, [ ["a", "b", "c"], ["a", true, 1] ]); - string[][]|csv:Error ct1bt1_4_3 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + string[][]|csv:Error ct1bt1_4_3 = csv:parseList([["a", "b", "c"], ["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_4_3, [ ["h1", "h2", "h3"], ["a", "true", "1"], ["a", "true", "1"] ]); - (int|boolean|string)[][]|csv:Error ct1bt1_4_4 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + (int|boolean|string)[][]|csv:Error ct1bt1_4_4 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_4_4, [ ["h1", "h2", "h3"] ]); - [string, boolean|string, int|string][]|csv:Error ct1bt1_5 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + [string, boolean|string, int|string][]|csv:Error ct1bt1_5 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_5, [ ["h1", "h2", "h3"], ["a", true, 1] ]); - ct1bt1_5 = csv:parseLists([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt1_5 = csv:parseList([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_5, [ ["h1", "h2", "h3"], ["a", true, 1] ]); - ct1bt1_5 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt1_5 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt1_5, [ ["h1", "h2", "h3"], ["a", true, 1], ["a", true, 1] ]); - [string...][]|csv:Error ct1bt2 = csv:parseLists([["1", "a"], ["1", "a"]]); + [string...][]|csv:Error ct1bt2 = csv:parseList([["1", "a"], ["1", "a"]]); test:assertEquals(ct1bt2, [ ["1", "a"], ["1", "a"] ]); - [string, boolean|string, int|string...][]|csv:Error ct1bt2_2 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + [string, boolean|string, int|string...][]|csv:Error ct1bt2_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt2_2, [ ["h1", "h2", "h3"], ["a", true, 1] ]); - [string...][]|csv:Error ct1bt2_3 = csv:parseLists([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + [string...][]|csv:Error ct1bt2_3 = csv:parseList([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt2_3, [ ["h1", "h2", "h3"], ["a", "true", "1"] ]); - ct1bt2_2 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + ct1bt2_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt2_2, [ ["h1", "h2", "h3"], ["a", true, 1], ["a", true, 1] ]); - string[2][1]|csv:Error ct1bt6 = csv:parseLists([["a", "b", "c"], ["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + string[2][1]|csv:Error ct1bt6 = csv:parseList([["a", "b", "c"], ["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headerRows: 2, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt6, [ ["h1"], ["a"] ]); - [string, boolean|string, int|string...][1]|csv:Error ct1bt6_2 = csv:parseLists([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + [string, boolean|string, int|string...][1]|csv:Error ct1bt6_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt6_2, [ ["h1", "h2", "h3"] ]); - [string...][1]|csv:Error ct1bt6_3 = csv:parseLists([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); + [string...][1]|csv:Error ct1bt6_3 = csv:parseList([["a", "true", "2"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true}); test:assertEquals(ct1bt6_3, [ ["h1", "h2", "h3"] ]); diff --git a/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_record_test.bal b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_record_test.bal index decf586..d1c2fa1 100644 --- a/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_record_test.bal +++ b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_record_test.bal @@ -20,55 +20,55 @@ import ballerina/test; @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType() { - StringRecord1Array|csv:Error st1sr1 = csv:parseLists([st1, st1], {}); + StringRecord1Array|csv:Error st1sr1 = csv:parseList([st1, st1], {}); test:assertTrue(st1sr1 is csv:Error); test:assertEquals((st1sr1).message(), common:generateErrorMessageForMissingRequiredField("s3")); - StringRecord1Array|csv:Error st2sr1 = csv:parseLists([st2, st2], {}); + StringRecord1Array|csv:Error st2sr1 = csv:parseList([st2, st2], {}); test:assertTrue(st2sr1 is csv:Error); test:assertEquals((st2sr1).message(), common:generateErrorMessageForMissingRequiredField("s3")); - StringRecord2Array|csv:Error st1sr2 = csv:parseLists([st1, st1], {}); + StringRecord2Array|csv:Error st1sr2 = csv:parseList([st1, st1], {}); test:assertTrue(st1sr2 is csv:Error); test:assertEquals((st1sr2).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\"]", "parse_list_types_tests:StringRecord2")); - StringRecord2Array|csv:Error st2sr2 = csv:parseLists([st2, st2], {}); + StringRecord2Array|csv:Error st2sr2 = csv:parseList([st2, st2], {}); test:assertTrue(st2sr2 is csv:Error); test:assertEquals((st2sr2).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\",\"a\",\"\"]","parse_list_types_tests:StringRecord2")); - StringRecord9Array|csv:Error st1sr9 = csv:parseLists([st1, st1], {}); + StringRecord9Array|csv:Error st1sr9 = csv:parseList([st1, st1], {}); test:assertTrue(st1sr9 is csv:Error); test:assertEquals((st1sr9).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\"]", "parse_list_types_tests:StringRecord9")); - StringRecord9Array|csv:Error st2sr9 = csv:parseLists([st2, st2], {}); + StringRecord9Array|csv:Error st2sr9 = csv:parseList([st2, st2], {}); test:assertTrue(st2sr9 is csv:Error); test:assertEquals((st2sr9).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\",\"a\",\"\"]","parse_list_types_tests:StringRecord9")); - StringRecord10Array|csv:Error st1sr10 = csv:parseLists([st1, st1], {}); + StringRecord10Array|csv:Error st1sr10 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr10, [ {'1: "string", '2: ""}, {'1: "string", '2: ""} ]); - StringRecord10Array|csv:Error st2sr10 = csv:parseLists([st2, st2], {}); + StringRecord10Array|csv:Error st2sr10 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr10, [ {'1: "string", '2: "", '3: "a", '4: ""}, {'1: "string", '2: "", '3: "a", '4: ""} ]); - StringRecord19Array|csv:Error st1sr19 = csv:parseLists([st1, st1], {}); + StringRecord19Array|csv:Error st1sr19 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr19, [ {s1: "", s2: "", "1": s1, "2": s2}, {s1: "", s2: "", "1": s1, "2": s2} ]); - StringRecord19Array|csv:Error st2sr19 = csv:parseLists([st2, st2], {}); + StringRecord19Array|csv:Error st2sr19 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr19, [ {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2}, {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord20Array|csv:Error st1sr20 = csv:parseLists([st1, st1], {}); + StringRecord20Array|csv:Error st1sr20 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr20, [ {s1: "", s2: ""}, {s1: "", s2: ""} @@ -77,71 +77,71 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType2() { - StringRecord20Array|csv:Error st2sr20 = csv:parseLists([st2, st2], {}); + StringRecord20Array|csv:Error st2sr20 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr20, [ {s1: "", s2: ""}, {s1: "", s2: ""} ]); - StringRecord21Array|csv:Error st1sr21 = csv:parseLists([st1, st1], {}); + StringRecord21Array|csv:Error st1sr21 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr21, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - StringRecord21Array|csv:Error st2sr21 = csv:parseLists([st2, st2], {}); + StringRecord21Array|csv:Error st2sr21 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr21, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord22Array|csv:Error st1sr22 = csv:parseLists([st1, st1], {}); + StringRecord22Array|csv:Error st1sr22 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr22, [ {s1: "", s2: "", "1": s1, "2": s2}, {s1: "", s2: "", "1": s1, "2": s2} ]); - StringRecord22Array|csv:Error st2sr22 = csv:parseLists([st2, st2], {}); + StringRecord22Array|csv:Error st2sr22 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr22, [ {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2}, {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord23Array|csv:Error st1sr23 = csv:parseLists([st1, st1], {}); + StringRecord23Array|csv:Error st1sr23 = csv:parseList([st1, st1], {}); test:assertEquals(st1sr23, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - StringRecord23Array|csv:Error st2sr23 = csv:parseLists([st2, st2], {}); + StringRecord23Array|csv:Error st2sr23 = csv:parseList([st2, st2], {}); test:assertEquals(st2sr23, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord15Array|csv:Error st1cr15 = csv:parseLists([st1, st1], {}); + CustomRecord15Array|csv:Error st1cr15 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr15, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord15Array|csv:Error st2cr15 = csv:parseLists([st2, st2], {}); + CustomRecord15Array|csv:Error st2cr15 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr15, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord16Array|csv:Error st1cr16 = csv:parseLists([st1, st1], {}); + CustomRecord16Array|csv:Error st1cr16 = csv:parseList([st1, st1], {}); test:assertTrue(st1cr16 is csv:Error); test:assertEquals((st1cr16).message(), common:generateErrorMessageForMissingRequiredField("3")); - CustomRecord16Array|csv:Error st2cr16 = csv:parseLists([st2, st2], {}); + CustomRecord16Array|csv:Error st2cr16 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr16, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord17Array|csv:Error st1cr17 = csv:parseLists([st1, st1], {}); + CustomRecord17Array|csv:Error st1cr17 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr17, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} @@ -150,59 +150,59 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType2() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType3() { - CustomRecord17Array|csv:Error st2cr17 = csv:parseLists([st2, st2], {}); + CustomRecord17Array|csv:Error st2cr17 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr17, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord18Array|csv:Error st1cr18 = csv:parseLists([st1, st1], {}); + CustomRecord18Array|csv:Error st1cr18 = csv:parseList([st1, st1], {}); test:assertTrue(st1cr18 is csv:Error); test:assertEquals((st1cr18).message(), common:generateErrorMessageForMissingRequiredField("3")); - CustomRecord18Array|csv:Error st2cr18 = csv:parseLists([st2, st2], {}); + CustomRecord18Array|csv:Error st2cr18 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr18, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord19Array|csv:Error st1cr19 = csv:parseLists([st1, st1], {}); + CustomRecord19Array|csv:Error st1cr19 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr19, [ {'1: s1, '2: s2, '3: "", '4: ""}, {'1: s1, '2: s2, '3: "", '4: ""} ]); - CustomRecord19Array|csv:Error st2cr19 = csv:parseLists([st2, st2], {}); + CustomRecord19Array|csv:Error st2cr19 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr19, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord20Array|csv:Error st1cr20 = csv:parseLists([st1, st1], {}); + CustomRecord20Array|csv:Error st1cr20 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr20, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord20Array|csv:Error st2cr20 = csv:parseLists([st2, st2], {}); + CustomRecord20Array|csv:Error st2cr20 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr20, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord21Array|csv:Error st1cr21 = csv:parseLists([st1, st1], {}); + CustomRecord21Array|csv:Error st1cr21 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr21, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord21Array|csv:Error st2cr21 = csv:parseLists([st2, st2], {}); + CustomRecord21Array|csv:Error st2cr21 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr21, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord22Array|csv:Error st1cr22 = csv:parseLists([st1, st1], {}); + CustomRecord22Array|csv:Error st1cr22 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr22, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} @@ -211,71 +211,71 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType3() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType4() { - CustomRecord22Array|csv:Error st2cr22 = csv:parseLists([st2, st2], {}); + CustomRecord22Array|csv:Error st2cr22 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr22, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord23Array|csv:Error st1cr23 = csv:parseLists([st1, st1], {}); + CustomRecord23Array|csv:Error st1cr23 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr23, [ {"1": s1, "2": s2, a: ""}, {"1": s1, "2": s2, a: ""} ]); - CustomRecord23Array|csv:Error st2cr23 = csv:parseLists([st2, st2], {}); + CustomRecord23Array|csv:Error st2cr23 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr23, [ {'1: s1, '2: s2, '3: s3, '4: s2, a: ""}, {'1: s1, '2: s2, '3: s3, '4: s2, a: ""} ]); - CustomRecord24Array|csv:Error st1cr24 = csv:parseLists([st1, st1], {}); + CustomRecord24Array|csv:Error st1cr24 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr24, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord24Array|csv:Error st2cr24 = csv:parseLists([st2, st2], {}); + CustomRecord24Array|csv:Error st2cr24 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr24, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord25Array|csv:Error st1cr25 = csv:parseLists([st1, st1], {}); + CustomRecord25Array|csv:Error st1cr25 = csv:parseList([st1, st1], {}); test:assertTrue(st1cr25 is csv:Error); test:assertEquals((st1cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1")); - CustomRecord25Array|csv:Error st2cr25 = csv:parseLists([st2, st2], {}); + CustomRecord25Array|csv:Error st2cr25 = csv:parseList([st2, st2], {}); test:assertTrue(st2cr25 is csv:Error); test:assertEquals((st2cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1")); - CustomRecord25Array|csv:Error st3cr25 = csv:parseLists([st3, st3], {}); + CustomRecord25Array|csv:Error st3cr25 = csv:parseList([st3, st3], {}); test:assertTrue(st3cr25 is csv:Error); test:assertEquals((st3cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1")); - CustomRecord25Array|csv:Error st4cr25 = csv:parseLists([st4, st4], {}); + CustomRecord25Array|csv:Error st4cr25 = csv:parseList([st4, st4], {}); test:assertTrue(st4cr25 is csv:Error); test:assertEquals((st4cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1")); - CustomRecord26Array|csv:Error st1cr26 = csv:parseLists([st1, st1], {}); + CustomRecord26Array|csv:Error st1cr26 = csv:parseList([st1, st1], {}); test:assertEquals(st1cr26 , [ {'1: s1}, {'1: s1} ]); - CustomRecord26Array|csv:Error st2cr26 = csv:parseLists([st2, st2], {}); + CustomRecord26Array|csv:Error st2cr26 = csv:parseList([st2, st2], {}); test:assertEquals(st2cr26 , [ {'1: s1}, {'1: s1} ]); - CustomRecord26Array|csv:Error st3cr26 = csv:parseLists([st3, st3], {}); + CustomRecord26Array|csv:Error st3cr26 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr26 , [ {'1: s1}, {'1: s1} ]); - CustomRecord26Array|csv:Error st4cr26 = csv:parseLists([st4, st4], {}); + CustomRecord26Array|csv:Error st4cr26 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr26 , [ {'1: s1}, {'1: s1} @@ -284,103 +284,103 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType4() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType5() { - StringRecord1Array|csv:Error st3sr1 = csv:parseLists([st3, st3], {}); + StringRecord1Array|csv:Error st3sr1 = csv:parseList([st3, st3], {}); test:assertTrue(st3sr1 is csv:Error); test:assertEquals((st3sr1).message(), common:generateErrorMessageForMissingRequiredField("s3")); - StringRecord1Array|csv:Error st4sr1 = csv:parseLists([st4, st4], {}); + StringRecord1Array|csv:Error st4sr1 = csv:parseList([st4, st4], {}); test:assertTrue(st4sr1 is csv:Error); test:assertEquals((st4sr1).message(), common:generateErrorMessageForMissingRequiredField("s3")); - StringRecord2Array|csv:Error st3sr2 = csv:parseLists([st3, st3], {}); + StringRecord2Array|csv:Error st3sr2 = csv:parseList([st3, st3], {}); test:assertTrue(st3sr2 is csv:Error); test:assertEquals((st3sr2).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\"]", "parse_list_types_tests:StringRecord2")); - StringRecord2Array|csv:Error st4sr2 = csv:parseLists([st4, st4], {}); + StringRecord2Array|csv:Error st4sr2 = csv:parseList([st4, st4], {}); test:assertTrue(st4sr2 is csv:Error); test:assertEquals((st4sr2).message(), common:generateErrorMessageForInvalidHeaders("[\"string\",\"\",\"a\",\"\"]","parse_list_types_tests:StringRecord2")); - StringRecord9Array|csv:Error st3sr9 = csv:parseLists([st3, st3], {}); + StringRecord9Array|csv:Error st3sr9 = csv:parseList([st3, st3], {}); test:assertTrue(st3sr9 is csv:Error); test:assertEquals((st3sr9).message(), common:generateErrorMessageForMissingRequiredField("s1")); - StringRecord9Array|csv:Error st4sr9 = csv:parseLists([st4, st4], {}); + StringRecord9Array|csv:Error st4sr9 = csv:parseList([st4, st4], {}); test:assertTrue(st4sr9 is csv:Error); test:assertEquals((st4sr9).message(), common:generateErrorMessageForMissingRequiredField("s1")); - StringRecord10Array|csv:Error st3sr10 = csv:parseLists([st3, st3], {}); + StringRecord10Array|csv:Error st3sr10 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr10, [ {'1: "string", '2: ""}, {'1: "string", '2: ""} ]); - StringRecord10Array|csv:Error st4sr10 = csv:parseLists([st4, st4], {}); + StringRecord10Array|csv:Error st4sr10 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr10, [ {'1: "string", '2: "", '3: "a", '4: ""}, {'1: "string", '2: "", '3: "a", '4: ""} ]); - StringRecord19Array|csv:Error st3sr19 = csv:parseLists([st3, st3], {}); + StringRecord19Array|csv:Error st3sr19 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr19, [ {s1: "", s2: "", "1": s1, "2": s2}, {s1: "", s2: "", "1": s1, "2": s2} ]); - StringRecord19Array|csv:Error st4sr19 = csv:parseLists([st4, st4], {}); + StringRecord19Array|csv:Error st4sr19 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr19, [ {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2}, {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord20Array|csv:Error st3sr20 = csv:parseLists([st3, st3], {}); + StringRecord20Array|csv:Error st3sr20 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr20, [ {s1: "", s2: ""}, {s1: "", s2: ""} ]); - StringRecord20Array|csv:Error st4sr20 = csv:parseLists([st4, st4], {}); + StringRecord20Array|csv:Error st4sr20 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr20, [ {s1: "", s2: ""}, {s1: "", s2: ""} ]); - StringRecord21Array|csv:Error st3sr21 = csv:parseLists([st3, st3], {}); + StringRecord21Array|csv:Error st3sr21 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr21, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - StringRecord21Array|csv:Error st4sr21 = csv:parseLists([st4, st4], {}); + StringRecord21Array|csv:Error st4sr21 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr21, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord22Array|csv:Error st3sr22 = csv:parseLists([st3, st3], {}); + StringRecord22Array|csv:Error st3sr22 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr22, [ {s1: "", s2: "", "1": s1, "2": s2}, {s1: "", s2: "", "1": s1, "2": s2} ]); - StringRecord22Array|csv:Error st4sr22 = csv:parseLists([st4, st4], {}); + StringRecord22Array|csv:Error st4sr22 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr22, [ {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2}, {s1: "", s2: "", '1: s1, '2: s2, '3: s3, '4: s2} ]); - StringRecord23Array|csv:Error st3sr23 = csv:parseLists([st3, st3], {}); + StringRecord23Array|csv:Error st3sr23 = csv:parseList([st3, st3], {}); test:assertEquals(st3sr23, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - StringRecord23Array|csv:Error st4sr23 = csv:parseLists([st4, st4], {}); + StringRecord23Array|csv:Error st4sr23 = csv:parseList([st4, st4], {}); test:assertEquals(st4sr23, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord15Array|csv:Error st3cr15 = csv:parseLists([st3, st3], {}); + CustomRecord15Array|csv:Error st3cr15 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr15, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} @@ -389,111 +389,111 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType5() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType6() { - CustomRecord15Array|csv:Error st4cr15 = csv:parseLists([st4, st4], {}); + CustomRecord15Array|csv:Error st4cr15 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr15, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord16Array|csv:Error st3cr16 = csv:parseLists([st3, st3], {}); + CustomRecord16Array|csv:Error st3cr16 = csv:parseList([st3, st3], {}); test:assertTrue(st3cr16 is csv:Error); test:assertEquals((st3cr16).message(), common:generateErrorMessageForMissingRequiredField("3")); - CustomRecord16Array|csv:Error st4cr16 = csv:parseLists([st4, st4], {}); + CustomRecord16Array|csv:Error st4cr16 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr16, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord17Array|csv:Error st3cr17 = csv:parseLists([st3, st3], {}); + CustomRecord17Array|csv:Error st3cr17 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr17, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord17Array|csv:Error st4cr17 = csv:parseLists([st4, st4], {}); + CustomRecord17Array|csv:Error st4cr17 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr17, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord18Array|csv:Error st3cr18 = csv:parseLists([st3, st3], {}); + CustomRecord18Array|csv:Error st3cr18 = csv:parseList([st3, st3], {}); test:assertTrue(st3cr18 is csv:Error); test:assertEquals((st3cr18).message(), common:generateErrorMessageForMissingRequiredField("3")); - CustomRecord18Array|csv:Error st4cr18 = csv:parseLists([st4, st4], {}); + CustomRecord18Array|csv:Error st4cr18 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr18, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord19Array|csv:Error st3cr19 = csv:parseLists([st3, st3], {}); + CustomRecord19Array|csv:Error st3cr19 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr19, [ {'1: s1, '2: s2, '3: "", '4: ""}, {'1: s1, '2: s2, '3: "", '4: ""} ]); - CustomRecord19Array|csv:Error st4cr19 = csv:parseLists([st4, st4], {}); + CustomRecord19Array|csv:Error st4cr19 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr19, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord20Array|csv:Error st3cr20 = csv:parseLists([st3, st3], {}); + CustomRecord20Array|csv:Error st3cr20 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr20, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord20Array|csv:Error st4cr20 = csv:parseLists([st4, st4], {}); + CustomRecord20Array|csv:Error st4cr20 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr20, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord21Array|csv:Error st3cr21 = csv:parseLists([st3, st3], {}); + CustomRecord21Array|csv:Error st3cr21 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr21, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord21Array|csv:Error st4cr21 = csv:parseLists([st4, st4], {}); + CustomRecord21Array|csv:Error st4cr21 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr21, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord22Array|csv:Error st3cr22 = csv:parseLists([st3, st3], {}); + CustomRecord22Array|csv:Error st3cr22 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr22, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord22Array|csv:Error st4cr22 = csv:parseLists([st4, st4], {}); + CustomRecord22Array|csv:Error st4cr22 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr22, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomRecord23Array|csv:Error st3cr23 = csv:parseLists([st3, st3], {}); + CustomRecord23Array|csv:Error st3cr23 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr23, [ {"1": s1, "2": s2, a: ""}, {"1": s1, "2": s2, a: ""} ]); - CustomRecord23Array|csv:Error st4cr23 = csv:parseLists([st4, st4], {}); + CustomRecord23Array|csv:Error st4cr23 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr23, [ {'1: s1, '2: s2, '3: s3, '4: s2, a: ""}, {'1: s1, '2: s2, '3: s3, '4: s2, a: ""} ]); - CustomRecord24Array|csv:Error st3cr24 = csv:parseLists([st3, st3], {}); + CustomRecord24Array|csv:Error st3cr24 = csv:parseList([st3, st3], {}); test:assertEquals(st3cr24, [ {"1": s1, "2": s2}, {"1": s1, "2": s2} ]); - CustomRecord24Array|csv:Error st4cr24 = csv:parseLists([st4, st4], {}); + CustomRecord24Array|csv:Error st4cr24 = csv:parseList([st4, st4], {}); test:assertEquals(st4cr24, [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} @@ -502,13 +502,13 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType6() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { - record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "c", "b"]}); + record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "c", "b"]}); test:assertEquals(ct1br4, [ {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1} ]); - record{() a; float b; decimal c; boolean d; int e; string f;}[]|csv:Error ct1br6 = csv:parseLists( + record{() a; float b; decimal c; boolean d; int e; string f;}[]|csv:Error ct1br6 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br6, [ @@ -516,7 +516,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { {a: (), b: 0, c: 2.23, d: true, e: 1, f: "a"} ]); - record{|decimal c; boolean d; int e; string f;|}[]|csv:Error ct1br7 = csv:parseLists( + record{|decimal c; boolean d; int e; string f;|}[]|csv:Error ct1br7 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br7, [ @@ -524,7 +524,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { {c: 2.23, d: true, e: 1, f: "a"} ]); - record{decimal c; boolean d; int e; string f;}[]|csv:Error ct1br8 = csv:parseLists( + record{decimal c; boolean d; int e; string f;}[]|csv:Error ct1br8 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br8, [ @@ -532,7 +532,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { {a: (), b: 0, c: 2.23, d: true, e: 1, f: "a"} ]); - record{|int|() a; float b; decimal? c; boolean d; int e; string f; string...;|}[]|csv:Error ct1br9 = csv:parseLists( + record{|int|() a; float b; decimal? c; boolean d; int e; string f; string...;|}[]|csv:Error ct1br9 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br9, [ @@ -540,7 +540,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { {a: (), b: 0, c: 2.23, d: true, e: 1, f: "a"} ]); - record{|int|() a; float b; decimal? c; string|boolean d; int|string e; string f; string...;|}[]|csv:Error ct1br9_2 = csv:parseLists( + record{|int|() a; float b; decimal? c; string|boolean d; int|string e; string f; string...;|}[]|csv:Error ct1br9_2 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br9_2, [ @@ -551,80 +551,80 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { - record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 0, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); + record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 0, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct1br4, [ {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1} ]); - record{string a; boolean b; int c;}[]|csv:Error ct1br4_2 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"]}); + record{string a; boolean b; int c;}[]|csv:Error ct1br4_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"]}); test:assertEquals(ct1br4_2, [ {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1} ]); - record{string a; boolean b; int c;}[]|csv:Error ct1br4_3 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); + record{string a; boolean b; int c;}[]|csv:Error ct1br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct1br4_3, [ {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1} ]); - record{string a; boolean b; int c;}[]|csv:Error ct1br4_4 = csv:parseLists( + record{string a; boolean b; int c;}[]|csv:Error ct1br4_4 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct1br4_4, [ {a: "a", b: true, c: 1} ]); - record{string a; boolean b; int c;}[]|csv:Error ct1br4_5 = csv:parseLists( + record{string a; boolean b; int c;}[]|csv:Error ct1br4_5 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, outputWithHeaders: true}); test:assertTrue(ct1br4_5 is csv:Error); test:assertEquals((ct1br4_5).message(), "Custom headers should be provided"); - record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_4_2 = csv:parseLists( + record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_4_2 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct1br4_4_2, [ {a: "a", b: true, c: 1} ]); - record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_5_2 = csv:parseLists( + record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_5_2 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, outputWithHeaders: true}); test:assertTrue(ct1br4_5_2 is csv:Error); test:assertEquals((ct1br4_5).message(), "Custom headers should be provided"); - map[]|csv:Error ct2br4_3 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); + map[]|csv:Error ct2br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct2br4_3, [ {a: "a", b: true, c: 1}, {a: "a", b: true, c: 1} ]); - map[]|csv:Error ct2br4_3_2 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 3, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); + map[]|csv:Error ct2br4_3_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 3, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct2br4_3_2, []); - map[]|csv:Error ct2br4_4 = csv:parseLists( + map[]|csv:Error ct2br4_4 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct2br4_4, [ {a: "a", b: true, c: 1} ]); - map[]|csv:Error ct2br4_5 = csv:parseLists( + map[]|csv:Error ct2br4_5 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct2br4_5, [ {a: "a", b: "true", c: "1"}, {a: "a", b: "true", c: "1"} ]); - map[]|csv:Error ct2br4_7 = csv:parseLists( + map[]|csv:Error ct2br4_7 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 4, customHeaders: ["a", "c", "b"], outputWithHeaders: true}); test:assertEquals(ct2br4_7, []); - map[]|csv:Error ct2br4_6 = csv:parseLists( + map[]|csv:Error ct2br4_6 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, outputWithHeaders: true}); test:assertTrue(ct2br4_6 is csv:Error); test:assertEquals((ct1br4_5).message(), "Custom headers should be provided"); - map[]|csv:Error ct2br4_8 = csv:parseLists( + map[]|csv:Error ct2br4_8 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct2br4_8, [ {"a": "a", "1": "1", "true": "true"}, @@ -632,7 +632,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { {"a": "a", "1": "1", "true": "true"} ]); - map[]|csv:Error ct2br4_8_2 = csv:parseLists( + map[]|csv:Error ct2br4_8_2 = csv:parseList( [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, outputWithHeaders: false}); test:assertEquals(ct2br4_8_2, [ {"a": "a", "1": "1", "true": "true"}, @@ -640,7 +640,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { {"a": "a", "1": "1", "true": "true"} ]); - map[]|csv:Error ct2br4_9 = csv:parseLists( + map[]|csv:Error ct2br4_9 = csv:parseList( [["a", "c", "b"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct2br4_9, [ {a: "a", b: "true", c: "2"}, @@ -649,7 +649,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { {a: "a", b: "true", c: "5"} ]); - map[]|csv:Error ct2br4_10 = csv:parseLists( + map[]|csv:Error ct2br4_10 = csv:parseList( [["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1, outputWithHeaders: true}); test:assertEquals(ct2br4_10, [ {a: "a", c: true, b: 2}, @@ -658,7 +658,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { {a: "a", c: true, b: 5} ]); - map[]|csv:Error ct2br4_10_2 = csv:parseLists( + map[]|csv:Error ct2br4_10_2 = csv:parseList( [["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1, outputWithHeaders: false}); test:assertEquals(ct2br4_10_2, [ {a: "a", c: true, b: 2}, @@ -667,7 +667,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { {a: "a", c: true, b: 5} ]); - ct2br4_10_2 = csv:parseLists( + ct2br4_10_2 = csv:parseList( [["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1, customHeaders: ["c", "d", "e"], outputWithHeaders: false}); test:assertEquals(ct2br4_10_2, [ {c: "a", e: true, d: 2}, @@ -679,7 +679,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() { @test:Config function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { - record{|decimal c; boolean|string d; int e; string f; string...;|}[]|csv:Error ct1br10 = csv:parseLists( + record{|decimal c; boolean|string d; int e; string f; string...;|}[]|csv:Error ct1br10 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br10, [ @@ -687,7 +687,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {a: "()", b: "0", c: 2.23, d: true, e: 1, f: "a"} ]); - record{|decimal? c; boolean d; int? e; string f; ()...;|}[]|csv:Error ct1br11 = csv:parseLists( + record{|decimal? c; boolean d; int? e; string f; ()...;|}[]|csv:Error ct1br11 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br11, [ @@ -695,7 +695,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {a: (), c: 2.23, d: true, e: 1, f: "a"} ]); - record{|()...;|}[]|csv:Error ct1br12 = csv:parseLists( + record{|()...;|}[]|csv:Error ct1br12 = csv:parseList( [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]], {customHeaders: ["f", "e", "d", "c", "b", "a"]}); test:assertEquals(ct1br12, [ @@ -703,7 +703,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {a: ()} ]); - record{|string?...;|}[]|csv:Error ct1br13 = csv:parseLists( + record{|string?...;|}[]|csv:Error ct1br13 = csv:parseList( [["a", "1"], ["a", "1"]], {customHeaders: ["f", "e"]}); test:assertEquals(ct1br13, [ @@ -711,7 +711,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {e: "1", f: "a"} ]); - record{|boolean...;|}[]|csv:Error ct1br14 = csv:parseLists( + record{|boolean...;|}[]|csv:Error ct1br14 = csv:parseList( [["2.23", "null"], ["7", "()"]], {customHeaders: ["b", "a"]}); test:assertEquals(ct1br14, [ @@ -719,7 +719,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {} ]); - map[]|csv:Error ct1br15 = csv:parseLists( + map[]|csv:Error ct1br15 = csv:parseList( [["2", "()"], ["2", "1"], ["()", "2"]], {customHeaders: ["f", "e"]}); test:assertEquals(ct1br15, [ @@ -728,7 +728,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { {e: 2, f: ()} ]); - record{|boolean...;|}[]|csv:Error ct1br16 = csv:parseLists( + record{|boolean...;|}[]|csv:Error ct1br16 = csv:parseList( [["2.23", "null"], ["7", "()"]], {customHeaders: ["b", "a"]}); test:assertEquals(ct1br16, [ @@ -741,7 +741,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() { function testArrayIndexesWithRecordAsExpectedType() { string[][] csv = [["1", "2", "3"], ["3", "4", "5"], ["5", "6", "7"], ["7", "8", "9"]]; - map[2]|csv:Error rec_2 = csv:parseLists(csv, {customHeaders: ["a", "b", "c"]}); + map[2]|csv:Error rec_2 = csv:parseList(csv, {customHeaders: ["a", "b", "c"]}); test:assertEquals(rec_2, [ {a: 1, b: 2, c: 3}, {a: 3, b: 4, c: 5} @@ -750,79 +750,79 @@ function testArrayIndexesWithRecordAsExpectedType() { @test:Config function testFromCsvWithTypeForTupleAndMapAsExpectedType() { - StringMapArray|csv:Error st1sma = csv:parseLists([st1, st1], {}); + StringMapArray|csv:Error st1sma = csv:parseList([st1, st1], {}); test:assertEquals(st1sma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - StringMapArray|csv:Error st2sma = csv:parseLists([st2, st2], {}); + StringMapArray|csv:Error st2sma = csv:parseList([st2, st2], {}); test:assertEquals(st2sma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - StringMapArray|csv:Error st3sma = csv:parseLists([st3, st3], {}); + StringMapArray|csv:Error st3sma = csv:parseList([st3, st3], {}); test:assertEquals(st3sma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - StringMapArray|csv:Error st4sma = csv:parseLists([st4, st4], {}); + StringMapArray|csv:Error st4sma = csv:parseList([st4, st4], {}); test:assertEquals(st4sma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - NillableIntUnionStringMapArray|csv:Error st1niusma = csv:parseLists([st1, st1], {}); + NillableIntUnionStringMapArray|csv:Error st1niusma = csv:parseList([st1, st1], {}); test:assertEquals(st1niusma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - NillableIntUnionStringMapArray|csv:Error st2niusma = csv:parseLists([st2, st2], {}); + NillableIntUnionStringMapArray|csv:Error st2niusma = csv:parseList([st2, st2], {}); test:assertEquals(st2niusma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - NillableIntUnionStringMapArray|csv:Error st3niusma = csv:parseLists([st3, st3], {}); + NillableIntUnionStringMapArray|csv:Error st3niusma = csv:parseList([st3, st3], {}); test:assertEquals(st3niusma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - NillableIntUnionStringMapArray|csv:Error st4niusma = csv:parseLists([st4, st4], {}); + NillableIntUnionStringMapArray|csv:Error st4niusma = csv:parseList([st4, st4], {}); test:assertEquals(st4niusma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - IntUnionStringMapArray|csv:Error st1iusma = csv:parseLists([st1, st1], {}); + IntUnionStringMapArray|csv:Error st1iusma = csv:parseList([st1, st1], {}); test:assertEquals(st1iusma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - IntUnionStringMapArray|csv:Error st2iusma = csv:parseLists([st2, st2], {}); + IntUnionStringMapArray|csv:Error st2iusma = csv:parseList([st2, st2], {}); test:assertEquals(st2iusma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - IntUnionStringMapArray|csv:Error st3iusma = csv:parseLists([st3, st3], {}); + IntUnionStringMapArray|csv:Error st3iusma = csv:parseList([st3, st3], {}); test:assertEquals(st3iusma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - IntUnionStringMapArray|csv:Error st4iusma = csv:parseLists([st4, st4], {}); + IntUnionStringMapArray|csv:Error st4iusma = csv:parseList([st4, st4], {}); test:assertEquals(st4iusma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - JsonMapArray|csv:Error st1jma = csv:parseLists([st1, st1], {}); + JsonMapArray|csv:Error st1jma = csv:parseList([st1, st1], {}); test:assertEquals(st1jma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} @@ -831,91 +831,91 @@ function testFromCsvWithTypeForTupleAndMapAsExpectedType() { @test:Config function testFromCsvWithTypeForTupleAndMapAsExpectedType2() { - JsonMapArray|csv:Error st2jma = csv:parseLists([st2, st2], {}); + JsonMapArray|csv:Error st2jma = csv:parseList([st2, st2], {}); test:assertEquals(st2jma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - JsonMapArray|csv:Error st3jma = csv:parseLists([st3, st3], {}); + JsonMapArray|csv:Error st3jma = csv:parseList([st3, st3], {}); test:assertEquals(st3jma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - JsonMapArray|csv:Error st4jma = csv:parseLists([st4, st4], {}); + JsonMapArray|csv:Error st4jma = csv:parseList([st4, st4], {}); test:assertEquals(st4jma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - AnydataMapArray|csv:Error st1anydma = csv:parseLists([st1, st1], {}); + AnydataMapArray|csv:Error st1anydma = csv:parseList([st1, st1], {}); test:assertEquals(st1anydma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - AnydataMapArray|csv:Error st2anydma = csv:parseLists([st2, st2], {}); + AnydataMapArray|csv:Error st2anydma = csv:parseList([st2, st2], {}); test:assertEquals(st2anydma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - AnydataMapArray|csv:Error st3anydma = csv:parseLists([st3, st3], {}); + AnydataMapArray|csv:Error st3anydma = csv:parseList([st3, st3], {}); test:assertEquals(st3anydma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - AnydataMapArray|csv:Error st4anydma = csv:parseLists([st4, st4], {}); + AnydataMapArray|csv:Error st4anydma = csv:parseList([st4, st4], {}); test:assertEquals(st4anydma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomMapArray|csv:Error st1cma = csv:parseLists([st1, st1], {}); + CustomMapArray|csv:Error st1cma = csv:parseList([st1, st1], {}); test:assertEquals(st1cma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - CustomMapArray|csv:Error st2cma = csv:parseLists([st2, st2], {}); + CustomMapArray|csv:Error st2cma = csv:parseList([st2, st2], {}); test:assertEquals(st2cma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - CustomMapArray|csv:Error st3cma = csv:parseLists([st3, st3], {}); + CustomMapArray|csv:Error st3cma = csv:parseList([st3, st3], {}); test:assertEquals(st3cma , [ {'1: s1, '2: s2}, {'1: s1, '2: s2} ]); - CustomMapArray|csv:Error st4cma = csv:parseLists([st4, st4], {}); + CustomMapArray|csv:Error st4cma = csv:parseList([st4, st4], {}); test:assertEquals(st4cma , [ {'1: s1, '2: s2, '3: s3, '4: s2}, {'1: s1, '2: s2, '3: s3, '4: s2} ]); - NilMapArray|csv:Error st1nma = csv:parseLists([st1, st1], {}); + NilMapArray|csv:Error st1nma = csv:parseList([st1, st1], {}); test:assertEquals(st1nma, ([ {}, {} ])); - IntegerMapArray|csv:Error st2ima = csv:parseLists([st2, st2], {}); + IntegerMapArray|csv:Error st2ima = csv:parseList([st2, st2], {}); test:assertEquals(st2ima, ([ {}, {} ])); - DecimalMapArray|csv:Error st3dma = csv:parseLists([st3, st3], {}); + DecimalMapArray|csv:Error st3dma = csv:parseList([st3, st3], {}); test:assertEquals(st3dma, ([ {}, {} ])); - BooleanMapArray|csv:Error st4bma = csv:parseLists([st4, st4], {}); + BooleanMapArray|csv:Error st4bma = csv:parseList([st4, st4], {}); test:assertEquals(st4bma, ([ {}, {} diff --git a/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_list_test.bal b/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_list_test.bal index 7909d26..93b4e74 100644 --- a/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_list_test.bal +++ b/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_list_test.bal @@ -673,10 +673,10 @@ function testsRecordsOutputWithHeadrs() { bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}], {outputWithHeaders: true}); test:assertEquals(bm3anyd3t_4, [{"a": 1, "b": 2}, {"c": 3, "d": 4}]); - bm3anyd3t_3 = csv:parseLists([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true}); + bm3anyd3t_3 = csv:parseList([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true}); test:assertEquals(bm3anyd3t_3, [["a", "b"], ["c", "d", "e"]]); - bm3anyd3t_4 = csv:parseLists([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true}); + bm3anyd3t_4 = csv:parseList([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true}); test:assertTrue(bm3anyd3t_4 is csv:Error); test:assertEquals(( bm3anyd3t_4).message(), "CSV data rows with varying headers are not yet supported"); } diff --git a/ballerina-tests/type-compatible-tests/tests/parse_type_compatibility_test.bal b/ballerina-tests/type-compatible-tests/tests/parse_type_compatibility_test.bal index b75d0a9..6fdd4fe 100644 --- a/ballerina-tests/type-compatible-tests/tests/parse_type_compatibility_test.bal +++ b/ballerina-tests/type-compatible-tests/tests/parse_type_compatibility_test.bal @@ -327,7 +327,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { readonly & int a; readonly & string b; (readonly & boolean) | (readonly & decimal) c; - }[]|csv:Error rt11a = csv:parseLists( + }[]|csv:Error rt11a = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {customHeaders: ["a", "b", "c"]}); test:assertEquals(rt11a , [ @@ -336,7 +336,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: 3, b: "string3", c: true} ]); - record{A a; B b; C c;}[]|csv:Error rt12a = csv:parseLists( + record{A a; B b; C c;}[]|csv:Error rt12a = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {customHeaders: ["a", "b", "c"]}); test:assertEquals(rt12a , [ @@ -345,14 +345,14 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: 3, b: "string3", c: true} ]); - record{A a; B b; C c;}[]|csv:Error rt12a_2 = csv:parseLists( + record{A a; B b; C c;}[]|csv:Error rt12a_2 = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {customHeaders: ["a", "b", "c"], stringConversion: false}); test:assertTrue(rt12a_2 is csv:Error); test:assertEquals((rt12a_2).message(), common:generateErrorMessageForInvalidFieldType("1", "a")); - record{string|decimal a; B b; C c;}[]|csv:Error rt12a_3 = csv:parseLists( + record{string|decimal a; B b; C c;}[]|csv:Error rt12a_3 = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {customHeaders: ["a", "b", "c"]}); test:assertEquals(rt12a_3 , [ @@ -361,7 +361,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: 3, b: "string3", c: true} ]); - record{A2 a; B2 b; C2 c;}[]|csv:Error rt13a = csv:parseLists( + record{A2 a; B2 b; C2 c;}[]|csv:Error rt13a = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {customHeaders: ["a", "b", "c"]}); test:assertEquals(rt13a , [ @@ -370,7 +370,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: 3, b: "string3", c: true} ]); - record{|A2 a; B2 b; C2...;|}[]|csv:Error rt14a = csv:parseLists( + record{|A2 a; B2 b; C2...;|}[]|csv:Error rt14a = csv:parseList( [["1", "string", "true", "string"], ["2", "string2", "false", "string2"], ["3", "string3", "true", "string3"]] , {customHeaders: ["a", "b", "c", "d"]}); @@ -380,7 +380,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: 3, b: "string3", c: true, d: "string3"} ]); - record{|C2...;|}[]|csv:Error rt15a = csv:parseLists( + record{|C2...;|}[]|csv:Error rt15a = csv:parseList( [["1", "string", "true", "string"], ["2", "string2", "false", "string2"], ["3", "string3", "true", "string3"]] , {customHeaders: ["a", "b", "c", "d"]}); @@ -390,7 +390,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { {a: "3", b: "string3", c: true, d: "string3"} ]); - record{|C2...;|}[]|csv:Error rt15a_2 = csv:parseLists( + record{|C2...;|}[]|csv:Error rt15a_2 = csv:parseList( [["1", "string", "true", "string"], ["2", "string2", "false", "string2"], ["3", "string3", "true", "string3"]], {stringConversion: false, customHeaders: ["a", "b", "c", "d"]}); @@ -401,7 +401,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { ]); [readonly & int, readonly & string, (readonly & boolean) | (readonly & decimal)][]|csv:Error rt16a = - csv:parseLists( + csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]]); @@ -412,7 +412,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { [3, "string3", true] ]); - [A, B, C][]|csv:Error rt17a = csv:parseLists( + [A, B, C][]|csv:Error rt17a = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]]); test:assertEquals(rt17a , [ @@ -421,13 +421,13 @@ function testFromCsvWithIntersectionTypeCompatibility2() { [3, "string3", true] ]); - [A, B, C][]|csv:Error rt17a_2 = csv:parseLists( + [A, B, C][]|csv:Error rt17a_2 = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]], {stringConversion: false}); test:assertTrue(rt17a_2 is csv:Error); test:assertEquals((rt17a_2).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "0", "type_compatible_tests:A")); - [A2, B2, C2][]|csv:Error rt18a = csv:parseLists( + [A2, B2, C2][]|csv:Error rt18a = csv:parseList( [["1", "string", "true"], ["2", "string2", "false"], ["3", "string3", "true"]]); test:assertEquals(rt18a , [ @@ -436,7 +436,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { [3, "string3", true] ]); - [A2, B2, C2...][]|csv:Error rt19a = csv:parseLists( + [A2, B2, C2...][]|csv:Error rt19a = csv:parseList( [["1", "string", "true", "string"], ["2", "string2", "false", "string2"], ["3", "string3", "true", "string3"]]); test:assertEquals(rt19a , [ @@ -445,7 +445,7 @@ function testFromCsvWithIntersectionTypeCompatibility2() { [3, "string3", true, "string3"] ]); - [C2...][]|csv:Error rt20a = csv:parseLists( + [C2...][]|csv:Error rt20a = csv:parseList( [["1", "string", "true", "string"], ["2", "string2", "false", "string2"], ["3", "string3", "true", "string3"]]); test:assertEquals(rt20a, [["1", "string",true, "string"], diff --git a/ballerina-tests/union-type-tests/tests/test_union_types_with_headers.bal b/ballerina-tests/union-type-tests/tests/test_union_types_with_headers.bal index b02000f..7066c6d 100644 --- a/ballerina-tests/union-type-tests/tests/test_union_types_with_headers.bal +++ b/ballerina-tests/union-type-tests/tests/test_union_types_with_headers.bal @@ -8,14 +8,14 @@ csv:TransformOptions op4 = {headersOrder: ["a", "b"], outputWithHeaders: true}; csv:ParseOptions op5 = {outputWithHeaders: true}; -csv:ParseListsOptions op6 = {outputWithHeaders: true}; -csv:ParseListsOptions op7 = {outputWithHeaders: true, headerRows: 1}; -csv:ParseListsOptions op8 = {outputWithHeaders: true, headerRows: 2}; -csv:ParseListsOptions op9 = {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b", "c", "d"]}; -csv:ParseListsOptions op10 = {outputWithHeaders: true, headerRows: 1, customHeaders: ["a", "b", "c", "d"]}; -csv:ParseListsOptions op11 = {outputWithHeaders: true, customHeaders: ["a", "b", "c", "d"]}; -csv:ParseListsOptions op12 = {headerRows: 1, customHeaders: ["a", "b", "c", "d"]}; -csv:ParseListsOptions op13 = {customHeaders: ["a", "b", "c", "d"]}; +csv:ParseListOptions op6 = {outputWithHeaders: true}; +csv:ParseListOptions op7 = {outputWithHeaders: true, headerRows: 1}; +csv:ParseListOptions op8 = {outputWithHeaders: true, headerRows: 2}; +csv:ParseListOptions op9 = {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b", "c", "d"]}; +csv:ParseListOptions op10 = {outputWithHeaders: true, headerRows: 1, customHeaders: ["a", "b", "c", "d"]}; +csv:ParseListOptions op11 = {outputWithHeaders: true, customHeaders: ["a", "b", "c", "d"]}; +csv:ParseListOptions op12 = {headerRows: 1, customHeaders: ["a", "b", "c", "d"]}; +csv:ParseListOptions op13 = {customHeaders: ["a", "b", "c", "d"]}; type UnionType1 boolean[][]|string[][]; @@ -135,120 +135,120 @@ function testTransformWithListWithOutputHeaders() { @test:Config function testParseListWithMapWithOutputHeaders() { - UnionType3|csv:Error psu3 = csv:parseLists(csv1); + UnionType3|csv:Error psu3 = csv:parseList(csv1); test:assertEquals(psu3, result7); - psu3 = csv:parseLists(csv1, op6); + psu3 = csv:parseList(csv1, op6); test:assertEquals(psu3, result7); - psu3 = csv:parseLists(csv1, op7); + psu3 = csv:parseList(csv1, op7); test:assertEquals(psu3, [{"1": 5, "2": 6, "3": 7, "4": 8}, {"1": 9, "2": 10, "3": 11, "4": 12}, {"1": 13, "2": 14, "3": 15, "4": 16}]); - psu3 = csv:parseLists(csv1, op9); + psu3 = csv:parseList(csv1, op9); test:assertEquals(psu3, [{"a": 9, "b": 10, "c": 11, "d": 12}, {"a": 13, "b": 14, "c": 15, "d": 16}]); - UnionType4|csv:Error psu4 = csv:parseLists(csv1); + UnionType4|csv:Error psu4 = csv:parseList(csv1); test:assertEquals(psu4, result8); - psu4 = csv:parseLists(csv1, op6); + psu4 = csv:parseList(csv1, op6); test:assertEquals(psu4, result8); - psu4 = csv:parseLists(csv1, op7); + psu4 = csv:parseList(csv1, op7); test:assertEquals(psu4, [{"1": "5", "2": "6", "3": "7", "4": "8"}, {"1": "9", "2": "10", "3": "11", "4": "12"}, {"1": "13", "2": "14", "3": "15", "4": "16"}]); - psu4 = csv:parseLists(csv1, op9); + psu4 = csv:parseList(csv1, op9); test:assertEquals(psu4, [{"a": "9", "b": "10", "c": "11", "d": "12"}, {"a": "13", "b": "14", "c": "15", "d": "16"}]); } @test:Config function testParseListWithListWithOutputHeaders() { - UnionType1|csv:Error psu1 = csv:parseLists(csv1); + UnionType1|csv:Error psu1 = csv:parseList(csv1); test:assertEquals(psu1, result4); - psu1 = csv:parseLists(csv1, op6); + psu1 = csv:parseList(csv1, op6); test:assertEquals(psu1, result4); - psu1 = csv:parseLists(csv1, op7); + psu1 = csv:parseList(csv1, op7); test:assertEquals(psu1, result4); - psu1 = csv:parseLists(csv1, op9); + psu1 = csv:parseList(csv1, op9); test:assertEquals(psu1, [["a","b","c","d"],["9","10","11","12"],["13","14","15","16"]]); - UnionType2|csv:Error psu2 = csv:parseLists(csv1); + UnionType2|csv:Error psu2 = csv:parseList(csv1); test:assertEquals(psu2, result4); - psu2 = csv:parseLists(csv1, op6); + psu2 = csv:parseList(csv1, op6); test:assertEquals(psu2, result4); - psu2 = csv:parseLists(csv1, op7); + psu2 = csv:parseList(csv1, op7); test:assertEquals(psu2, result4); - psu2 = csv:parseLists(csv1, op9); + psu2 = csv:parseList(csv1, op9); test:assertEquals(psu2, [["a","b","c","d"],["9","10","11","12"],["13","14","15","16"]]); } @test:Config function testParseListWithMapWithOutputHeaders2() { - UnionType3|csv:Error psu3 = csv:parseLists(csv1); + UnionType3|csv:Error psu3 = csv:parseList(csv1); test:assertEquals(psu3, result7); - psu3 = csv:parseLists(csv1, op10); + psu3 = csv:parseList(csv1, op10); test:assertEquals(psu3, [{"a":5,"b":6,"c":7,"d":8},{"a":9,"b":10,"c":11,"d":12},{"a":13,"b":14,"c":15,"d":16}]); - psu3 = csv:parseLists(csv1, op11); + psu3 = csv:parseList(csv1, op11); test:assertEquals(psu3, result2); - psu3 = csv:parseLists(csv1, op12); + psu3 = csv:parseList(csv1, op12); test:assertEquals(psu3, [{"a":5,"b":6,"c":7,"d":8},{"a":9,"b":10,"c":11,"d":12},{"a":13,"b":14,"c":15,"d":16}]); - psu3 = csv:parseLists(csv1, op13); + psu3 = csv:parseList(csv1, op13); test:assertEquals(psu3, result2); - UnionType4|csv:Error psu4 = csv:parseLists(csv1); + UnionType4|csv:Error psu4 = csv:parseList(csv1); test:assertEquals(psu4, result8); - psu4 = csv:parseLists(csv1, op10); + psu4 = csv:parseList(csv1, op10); test:assertEquals(psu4, [{a: "5", b: "6", c: "7", d: "8"}, {a: "9", b: "10", c: "11", d: "12"}, {a: "13", b: "14", c: "15", d: "16"}]); - psu4 = csv:parseLists(csv1, op11); + psu4 = csv:parseList(csv1, op11); test:assertEquals(psu4, result3); - psu4 = csv:parseLists(csv1, op12); + psu4 = csv:parseList(csv1, op12); test:assertEquals(psu4, [{a: "5", b: "6", c: "7", d: "8"}, {a: "9", b: "10", c: "11", d: "12"}, {a: "13", b: "14", c: "15", d: "16"}]); - psu4 = csv:parseLists(csv1, op13); + psu4 = csv:parseList(csv1, op13); test:assertEquals(psu4, result3); } @test:Config function testParseListWithListWithOutputHeaders2() { - UnionType1|csv:Error psu1 = csv:parseLists(csv1); + UnionType1|csv:Error psu1 = csv:parseList(csv1); test:assertEquals(psu1, result4); - psu1 = csv:parseLists(csv1, op10); + psu1 = csv:parseList(csv1, op10); test:assertEquals(psu1, [["a","b","c","d"],["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); - psu1 = csv:parseLists(csv1, op11); + psu1 = csv:parseList(csv1, op11); test:assertEquals(psu1, result6); - psu1 = csv:parseLists(csv1, op12); + psu1 = csv:parseList(csv1, op12); test:assertEquals(psu1, [["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); - psu1 = csv:parseLists(csv1, op13); + psu1 = csv:parseList(csv1, op13); test:assertEquals(psu1, result4); - UnionType2|csv:Error psu2 = csv:parseLists(csv1); + UnionType2|csv:Error psu2 = csv:parseList(csv1); test:assertEquals(psu2, result4); - psu2 = csv:parseLists(csv1, op10); + psu2 = csv:parseList(csv1, op10); test:assertEquals(psu2, [["a","b","c","d"],["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); - psu2 = csv:parseLists(csv1, op11); + psu2 = csv:parseList(csv1, op11); test:assertEquals(psu2, [["a","b","c","d"], ["1", "2", "3", "4"],["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); - psu2 = csv:parseLists(csv1, op12); + psu2 = csv:parseList(csv1, op12); test:assertEquals(psu2, [["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); - psu2 = csv:parseLists(csv1, op13); + psu2 = csv:parseList(csv1, op13); test:assertEquals(psu2, [["1", "2", "3", "4"],["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]); } diff --git a/ballerina-tests/union-type-tests/tests/test_with_intersection_types.bal b/ballerina-tests/union-type-tests/tests/test_with_intersection_types.bal index 66a06fa..5d37b8b 100644 --- a/ballerina-tests/union-type-tests/tests/test_with_intersection_types.bal +++ b/ballerina-tests/union-type-tests/tests/test_with_intersection_types.bal @@ -126,49 +126,49 @@ function testIntersectionExpectedTypes2() returns error? { @test:Config function testIntersectionExpectedTypes3() returns error? { - (int[] & readonly)[]|csv:Error a = csv:parseLists([["1", "2"], ["4", "5"]], {}); + (int[] & readonly)[]|csv:Error a = csv:parseList([["1", "2"], ["4", "5"]], {}); test:assertTrue(a is (int[] & readonly)[]); test:assertEquals(a, [[1, 2], [4, 5]]); - ([string, string])[] & readonly|csv:Error a2 = csv:parseLists([["a", "a"], ["c", "c"]], {}); + ([string, string])[] & readonly|csv:Error a2 = csv:parseList([["a", "a"], ["c", "c"]], {}); test:assertTrue(a2 is [string, string][] & readonly); test:assertEquals(a2, [["a", "a"], ["c", "c"]]); - (record {int a; string b;} & readonly)[]|csv:Error a3 = csv:parseLists([["1", "2"], ["4", "5"]], {customHeaders: ["a", "b"]}); + (record {int a; string b;} & readonly)[]|csv:Error a3 = csv:parseList([["1", "2"], ["4", "5"]], {customHeaders: ["a", "b"]}); test:assertTrue(a3 is (record {int a; string b;} & readonly)[]); test:assertEquals(a3, [{a: 1, b: "2"}, {a: 4, b: "5"}]); - record {|string...;|}[] & readonly|csv:Error a4 = csv:parseLists([["a", "a"], ["c", "c"]], {customHeaders: ["a", "b"]}); + record {|string...;|}[] & readonly|csv:Error a4 = csv:parseList([["a", "a"], ["c", "c"]], {customHeaders: ["a", "b"]}); test:assertTrue(a4 is record {|string...;|}[] & readonly); test:assertEquals(a4, [{a: "a", b: "a"}, {a: "c", b: "c"}]); - ([int] & readonly)[]|csv:Error a5 = csv:parseLists([["1", "2"], ["4", "5"]], {}); + ([int] & readonly)[]|csv:Error a5 = csv:parseList([["1", "2"], ["4", "5"]], {}); test:assertTrue(a5 is ([int] & readonly)[]); test:assertEquals(a5, [[1], [4]]); - ([string, string])[] & readonly|csv:Error a6 = csv:parseLists([["a", "a"], ["c", "c"]], {}); + ([string, string])[] & readonly|csv:Error a6 = csv:parseList([["a", "a"], ["c", "c"]], {}); test:assertTrue(a6 is [string, string][] & readonly); test:assertEquals(a6, [["a", "a"], ["c", "c"]]); - (record {int a; string b;} & readonly)[]|csv:Error a7 = csv:parseLists([["1", "2"], ["4", "5"]], {customHeaders: ["a", "b"]}); + (record {int a; string b;} & readonly)[]|csv:Error a7 = csv:parseList([["1", "2"], ["4", "5"]], {customHeaders: ["a", "b"]}); test:assertTrue(a7 is record {int a; string b;}[] & readonly); test:assertEquals(a7, [{a: 1, b: "2"}, {a: 4, b: "5"}]); - map[] & readonly|csv:Error a8 = csv:parseLists([["a", "a"], ["c", "c"]], {customHeaders: ["a", "b"]}); + map[] & readonly|csv:Error a8 = csv:parseList([["a", "a"], ["c", "c"]], {customHeaders: ["a", "b"]}); test:assertTrue(a8 is map[] & readonly); test:assertEquals(a8, [{a: "a", b: "a"}, {a: "c", b: "c"}]); - (((int[] & readonly)|([string, string] & readonly)) & readonly)[]|csv:Error a9 = csv:parseLists([["1", "2"], ["a", "b"]], {}); + (((int[] & readonly)|([string, string] & readonly)) & readonly)[]|csv:Error a9 = csv:parseList([["1", "2"], ["a", "b"]], {}); test:assertTrue(a9 is (((int[] & readonly)|([string, string] & readonly)) & readonly)[]); test:assertEquals(a9, [[1, 2], ["a", "b"]]); ((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[] - & readonly|csv:Error a10 = csv:parseLists([["a", "a"], ["1", "2"]], {customHeaders: ["a", "b"]}); + & readonly|csv:Error a10 = csv:parseList([["a", "a"], ["1", "2"]], {customHeaders: ["a", "b"]}); test:assertTrue(a10 is ((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[] & readonly); test:assertEquals(a10, [{a: "a", b: "a"}, {a: "1", b: "2"}]); ((record {int a; int b;} & readonly)|(record {string a; string b;} & readonly))[] - & readonly|csv:Error a11 = csv:parseLists([["a", "a"], ["1", "2"]], {customHeaders: ["a", "b"]}); + & readonly|csv:Error a11 = csv:parseList([["a", "a"], ["1", "2"]], {customHeaders: ["a", "b"]}); test:assertTrue(a11 is ((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[] & readonly); test:assertEquals(a11, [{a: "a", b: "a"}, {a: 1, b: 2}]); } diff --git a/ballerina-tests/union-type-tests/tests/test_with_singleton_test.bal b/ballerina-tests/union-type-tests/tests/test_with_singleton_test.bal index f0ca784..cf6a55a 100644 --- a/ballerina-tests/union-type-tests/tests/test_with_singleton_test.bal +++ b/ballerina-tests/union-type-tests/tests/test_with_singleton_test.bal @@ -193,21 +193,21 @@ function testSubtypeExpectedTypes() returns error? { SubtypeTuple3[]|csv:Error a12 = csv:transform(value1, {headersOrder: ["a", "c", "d", "e", "f", "g", "h", "i"]}); test:assertEquals(a12, value3); - SubtypeRecord[]|csv:Error a13 = csv:parseLists(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); + SubtypeRecord[]|csv:Error a13 = csv:parseList(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); test:assertEquals(a13, value1); - SubtypeRecord2[]|csv:Error a14 = csv:parseLists(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); + SubtypeRecord2[]|csv:Error a14 = csv:parseList(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); test:assertEquals(a14, [{a: 1, c: 1}, {a: 1, c: 1}]); - SubtypeRecord3[]|csv:Error a15 = csv:parseLists(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); + SubtypeRecord3[]|csv:Error a15 = csv:parseList(value2, {customHeaders: ["a", "c", "d", "e", "f", "g", "h", "i"]}); test:assertEquals(a15, value1); - SubtypeTuple[]|csv:Error a16 = csv:parseLists(value2, {}); + SubtypeTuple[]|csv:Error a16 = csv:parseList(value2, {}); test:assertEquals(a16, value3); - SubtypeTuple2[]|csv:Error a17 = csv:parseLists(value2, {}); + SubtypeTuple2[]|csv:Error a17 = csv:parseList(value2, {}); test:assertEquals(a17, [[1, 1], [1, 1]]); - SubtypeTuple3[]|csv:Error a18 = csv:parseLists(value2, {}); + SubtypeTuple3[]|csv:Error a18 = csv:parseList(value2, {}); test:assertEquals(a18, value3); } diff --git a/ballerina-tests/union-type-tests/tests/test_with_union_types.bal b/ballerina-tests/union-type-tests/tests/test_with_union_types.bal index 0e5ccf4..0d216d2 100644 --- a/ballerina-tests/union-type-tests/tests/test_with_union_types.bal +++ b/ballerina-tests/union-type-tests/tests/test_with_union_types.bal @@ -252,7 +252,7 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { ["5", "string5", "true", "3", "3.0", "()"] ]; - (RecA|RecC)[]|csv:Error csv1op1 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); + (RecA|RecC)[]|csv:Error csv1op1 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); test:assertEquals(csv1op1, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 2, b: "string2", c: false, d: 0, e: 0, f: ()}, @@ -261,7 +261,7 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - (RecA|RecC)[]|csv:Error csv1op2 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (RecA|RecC)[]|csv:Error csv1op2 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertTrue(csv1op2 is (RecA|RecC)[]); test:assertEquals(csv1op2, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, @@ -269,49 +269,49 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - (RecC|RecA)[]|csv:Error csv1op3 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (RecC|RecA)[]|csv:Error csv1op3 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op3, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 3, b: "string3", c: false, d: 1.23, e: 1.23, f: ()}, {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - (RecB|RecA)[]|csv:Error csv1op4 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (RecB|RecA)[]|csv:Error csv1op4 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op4, [ {a: "1", b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: "3", b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: "5", b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - (RecA|RecB)[]|csv:Error csv1op5 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (RecA|RecB)[]|csv:Error csv1op5 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op5, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 3, b: "string3", c: false, d: 1.23, e: 1.23, f: ()}, {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - (record{|int a;|}|record{|string b;|})[]|csv:Error csv1op6 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (record{|int a;|}|record{|string b;|})[]|csv:Error csv1op6 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op6, [ {a: 1}, {a: 3}, {a: 5} ]); - (record{|string b;|}|record{|int a;|})[]|csv:Error csv1op7 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + (record{|string b;|}|record{|int a;|})[]|csv:Error csv1op7 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op7, [ {b: "string1"}, {b: "string3"}, {b: "string5"} ]); - (record{|string...;|}|record{|int...;|})[]|csv:Error csv1op8 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [4, 2]}); + (record{|string...;|}|record{|int...;|})[]|csv:Error csv1op8 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [4, 2]}); test:assertEquals(csv1op8, [ {a: "1", b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: "3", b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: "5", b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - (record{|int...;|}|record{|string...;|})[]|csv:Error csv1op9 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: true}); + (record{|int...;|}|record{|string...;|})[]|csv:Error csv1op9 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: true}); test:assertEquals(csv1op9, [ {a: 1}, {a: 2, d: 0, e: 0}, @@ -320,7 +320,7 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { {a: 5, d: 3} ]); - (record{|int...;|}|record{|string...;|})[]|csv:Error csv1op9_2 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); + (record{|int...;|}|record{|string...;|})[]|csv:Error csv1op9_2 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); test:assertEquals(csv1op9_2, [ {}, {}, @@ -329,14 +329,14 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { {} ]); - (record{|int a; string...;|}|record{|string a; int...;|})[]|csv:Error csv1op10 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, -1, 4]}); + (record{|int a; string...;|}|record{|string a; int...;|})[]|csv:Error csv1op10 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, -1, 4]}); test:assertEquals(csv1op10, [ {a: 1, b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: 3, b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: 5, b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - (record{|string a; int...;|}|record{|int a; string...;|})[]|csv:Error csv1op11 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); + (record{|string a; int...;|}|record{|int a; string...;|})[]|csv:Error csv1op11 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); test:assertEquals(csv1op11, [ {a: "1"}, {a: "2", d: 0, e: 0}, @@ -345,11 +345,11 @@ function testParseToStringWithUnionExpectedTypes3() returns error? { {a: "5", d: 3} ]); - (record{|int a; int...;|}|record{|int a; string...;|})[]|csv:Error csv1op12 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); + (record{|int a; int...;|}|record{|int a; string...;|})[]|csv:Error csv1op12 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); test:assertTrue(csv1op12 is csv:Error); test:assertEquals((csv1op12).message(), "The source value cannot convert in to the '(union_type_tests:record {| int a; int...; |}|union_type_tests:record {| int a; string...; |})[]'"); - (record{|int a; int...;|}|record{|string a; string...;|})[]|csv:Error csv1op13 = csv:parseLists([["1", "2"], ["a", "b"]], {customHeaders: ["a", "b"]}); + (record{|int a; int...;|}|record{|string a; string...;|})[]|csv:Error csv1op13 = csv:parseList([["1", "2"], ["a", "b"]], {customHeaders: ["a", "b"]}); test:assertEquals(csv1op13, [ {a: 1, b: 2}, {a: "a", b: "b"} @@ -460,7 +460,7 @@ function testParseToStringWithUnionExpectedTypes5() returns error? { ["5", "string5", "true", "3", "3.0", "()"] ]; - (TupA|TupC)[]|csv:Error csv1op1 = csv:parseLists(value, {}); + (TupA|TupC)[]|csv:Error csv1op1 = csv:parseList(value, {}); test:assertEquals(csv1op1, [ [1, "string1", true, 2.234, 2.234, ()], [2, "string2", false, 0, 0, ()], @@ -469,7 +469,7 @@ function testParseToStringWithUnionExpectedTypes5() returns error? { [5, "string5", true, 3, 3.0, ()] ]); - (TupA|TupC)[]|csv:Error csv1op2 = csv:parseLists(value, {skipLines: [2, 4]}); + (TupA|TupC)[]|csv:Error csv1op2 = csv:parseList(value, {skipLines: [2, 4]}); test:assertTrue(csv1op2 is (TupA|TupC)[]); test:assertEquals(csv1op2, [ [1, "string1", true, 2.234, 2.234, ()], @@ -477,56 +477,56 @@ function testParseToStringWithUnionExpectedTypes5() returns error? { [5, "string5", true, 3, 3.0, ()] ]); - (TupC|TupA)[]|csv:Error csv1op3 = csv:parseLists(value, {skipLines: [2, 4]}); + (TupC|TupA)[]|csv:Error csv1op3 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op3, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - (TupB|TupA)[]|csv:Error csv1op4 = csv:parseLists(value, {skipLines: [2, 4]}); + (TupB|TupA)[]|csv:Error csv1op4 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op4, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - (TupB|[boolean])[]|csv:Error csv1op4_2 = csv:parseLists(value, {skipLines: [2, 4]}); + (TupB|[boolean])[]|csv:Error csv1op4_2 = csv:parseList(value, {skipLines: [2, 4]}); test:assertTrue(csv1op4_2 is csv:Error); test:assertEquals((csv1op4_2).message(), "The source value cannot convert in to the '(union_type_tests:TupB|[boolean])[]'"); - (TupA|TupB)[]|csv:Error csv1op5 = csv:parseLists(value, {skipLines: [2, 4]}); + (TupA|TupB)[]|csv:Error csv1op5 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op5, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - ([int]|[string])[]|csv:Error csv1op6 = csv:parseLists(value, {skipLines: [2, 4]}); + ([int]|[string])[]|csv:Error csv1op6 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op6, [ [1], [3], [5] ]); - ([string]|[int])[]|csv:Error csv1op7 = csv:parseLists(value, {skipLines: [2, 4]}); + ([string]|[int])[]|csv:Error csv1op7 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op7, [ ["1"], ["3"], ["5"] ]); - ([boolean...]|[int...])[]|csv:Error csv1op8 = csv:parseLists(value, {stringConversion: false}); + ([boolean...]|[int...])[]|csv:Error csv1op8 = csv:parseList(value, {stringConversion: false}); test:assertTrue(csv1op8 is csv:Error); test:assertEquals((csv1op8).message(), "The source value cannot convert in to the '([boolean...]|[int...])[]'"); - ([string...]|[int...])[]|csv:Error csv1op8_2 = csv:parseLists(value, {}); + ([string...]|[int...])[]|csv:Error csv1op8_2 = csv:parseList(value, {}); test:assertEquals(csv1op8_2, value); - ([int...]|[string...])[]|csv:Error csv1op9 = csv:parseLists(value, {}); + ([int...]|[string...])[]|csv:Error csv1op9 = csv:parseList(value, {}); test:assertEquals(csv1op9, value); - ([int, string...]|[string, int...])[]|csv:Error csv1op10 = csv:parseLists(value, {}); + ([int, string...]|[string, int...])[]|csv:Error csv1op10 = csv:parseList(value, {}); test:assertEquals(csv1op10, [ [1, "string1", "true", "2.234", "2.234", "()"], [2, "string2", "false", "0", "0", "()"], @@ -535,7 +535,7 @@ function testParseToStringWithUnionExpectedTypes5() returns error? { [5, "string5", "true", "3", "3.0", "()"] ]); - ([string, int...]|[int, string...])[]|csv:Error csv1op11 = csv:parseLists(value, {}); + ([string, int...]|[int, string...])[]|csv:Error csv1op11 = csv:parseList(value, {}); test:assertEquals(csv1op11, [ [1, "string1", "true", "2.234", "2.234", "()"], [2, "string2", "false", "0", "0", "()"], @@ -544,10 +544,10 @@ function testParseToStringWithUnionExpectedTypes5() returns error? { [5, "string5", "true", "3", "3.0", "()"] ]); - ([string, int...]|[string, string...])[]|csv:Error csv1op12 = csv:parseLists(value, {}); + ([string, int...]|[string, string...])[]|csv:Error csv1op12 = csv:parseList(value, {}); test:assertEquals(csv1op12, value); - ([int, int...]|[string, string...])[]|csv:Error csv1op13 = csv:parseLists([["1", "2"], ["a", "b"]], {}); + ([int, int...]|[string, string...])[]|csv:Error csv1op13 = csv:parseList([["1", "2"], ["a", "b"]], {}); test:assertEquals(csv1op13, [ [1, 2], ["a", "b"] @@ -767,7 +767,7 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { ["5", "string5", "true", "3", "3.0", "()"] ]; - RecA[]|RecC[]|csv:Error csv1op1 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); + RecA[]|RecC[]|csv:Error csv1op1 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); test:assertEquals(csv1op1, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 2, b: "string2", c: false, d: 0, e: 0, f: ()}, @@ -776,7 +776,7 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - RecA[]|RecC[]|csv:Error csv1op2 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + RecA[]|RecC[]|csv:Error csv1op2 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertTrue(csv1op2 is RecA[]|RecC[]); test:assertEquals(csv1op2, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, @@ -784,49 +784,49 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - RecC[]|RecA[]|csv:Error csv1op3 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + RecC[]|RecA[]|csv:Error csv1op3 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op3, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 3, b: "string3", c: false, d: 1.23, e: 1.23, f: ()}, {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - RecB[]|RecA[]|csv:Error csv1op4 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + RecB[]|RecA[]|csv:Error csv1op4 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op4, [ {a: "1", b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: "3", b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: "5", b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - RecA[]|RecB[]|csv:Error csv1op5 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + RecA[]|RecB[]|csv:Error csv1op5 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op5, [ {a: 1, b: "string1", c: true, d: 2.234, e: 2.234, f: ()}, {a: 3, b: "string3", c: false, d: 1.23, e: 1.23, f: ()}, {a: 5, b: "string5", c: true, d: 3, e: 3.0, f: ()} ]); - record{|int a;|}[]|record{|string b;|}[]|csv:Error csv1op6 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + record{|int a;|}[]|record{|string b;|}[]|csv:Error csv1op6 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op6, [ {a: 1}, {a: 3}, {a: 5} ]); - record{|string b;|}[]|record{|int a;|}[]|csv:Error csv1op7 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); + record{|string b;|}[]|record{|int a;|}[]|csv:Error csv1op7 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, 4]}); test:assertEquals(csv1op7, [ {b: "string1"}, {b: "string3"}, {b: "string5"} ]); - record{|string...;|}[]|record{|int...;|}[]|csv:Error csv1op8 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [4, 2]}); + record{|string...;|}[]|record{|int...;|}[]|csv:Error csv1op8 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [4, 2]}); test:assertEquals(csv1op8, [ {a: "1", b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: "3", b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: "5", b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - record{|int...;|}[]|record{|string...;|}[]|csv:Error csv1op9 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: true}); + record{|int...;|}[]|record{|string...;|}[]|csv:Error csv1op9 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: true}); test:assertEquals(csv1op9, [ {a: 1}, {a: 2, d: 0, e: 0}, @@ -835,7 +835,7 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { {a: 5, d: 3} ]); - record{|int...;|}[]|record{|string...;|}[]|csv:Error csv1op9_2 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); + record{|int...;|}[]|record{|string...;|}[]|csv:Error csv1op9_2 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); test:assertEquals(csv1op9_2, [ {}, {}, @@ -844,14 +844,14 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { {} ]); - record{|int a; string...;|}[]|record{|string a; int...;|}[]|csv:Error csv1op10 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, -1, 4]}); + record{|int a; string...;|}[]|record{|string a; int...;|}[]|csv:Error csv1op10 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], skipLines: [2, -1, 4]}); test:assertEquals(csv1op10, [ {a: 1, b: "string1", c: "true", d: "2.234", e: "2.234", f: "()"}, {a: 3, b: "string3", c: "false", d: "1.23", e: "1.23", f: "()"}, {a: 5, b: "string5", c: "true", d: "3", e: "3.0", f: "()"} ]); - record{|string a; int...;|}[]|record{|int a; string...;|}[]|csv:Error csv1op11 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); + record{|string a; int...;|}[]|record{|int a; string...;|}[]|csv:Error csv1op11 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"]}); test:assertEquals(csv1op11, [ {a: "1"}, {a: "2", d: 0, e: 0}, @@ -860,11 +860,11 @@ function testParseToStringWithUnionExpectedTypes8() returns error? { {a: "5", d: 3} ]); - record{|int a; int...;|}[]|record{|int a; string...;|}[]|csv:Error csv1op12 = csv:parseLists(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); + record{|int a; int...;|}[]|record{|int a; string...;|}[]|csv:Error csv1op12 = csv:parseList(value, {customHeaders: ["a", "b", "c", "d", "e", "f"], stringConversion: false}); test:assertTrue(csv1op12 is csv:Error); test:assertEquals((csv1op12).message(), "The source value cannot convert in to the '(union_type_tests:record {| int a; int...; |}[]|union_type_tests:record {| int a; string...; |}[])'"); - record{|int a; int...;|}[]|record{|string a; string...;|}[]|csv:Error csv1op13 = csv:parseLists([["1", "2"], ["a", "b"]], {customHeaders: ["a", "b"]}); + record{|int a; int...;|}[]|record{|string a; string...;|}[]|csv:Error csv1op13 = csv:parseList([["1", "2"], ["a", "b"]], {customHeaders: ["a", "b"]}); test:assertEquals(csv1op13, [ {a: "1", b: "2"}, {a: "a", b: "b"} @@ -969,7 +969,7 @@ function testParseToStringWithUnionExpectedTypes10() returns error? { ["5", "string5", "true", "3", "3.0", "()"] ]; - TupA[]|TupC[]|csv:Error csv1op1 = csv:parseLists(value, {}); + TupA[]|TupC[]|csv:Error csv1op1 = csv:parseList(value, {}); test:assertEquals(csv1op1, [ [1, "string1", true, 2.234, 2.234, ()], [2, "string2", false, 0, 0, ()], @@ -978,7 +978,7 @@ function testParseToStringWithUnionExpectedTypes10() returns error? { [5, "string5", true, 3, 3.0, ()] ]); - TupA[]|TupC[]|csv:Error csv1op2 = csv:parseLists(value, {skipLines: [2, 4]}); + TupA[]|TupC[]|csv:Error csv1op2 = csv:parseList(value, {skipLines: [2, 4]}); test:assertTrue(csv1op2 is TupA[]|TupC[]); test:assertEquals(csv1op2, [ [1, "string1", true, 2.234, 2.234, ()], @@ -986,56 +986,56 @@ function testParseToStringWithUnionExpectedTypes10() returns error? { [5, "string5", true, 3, 3.0, ()] ]); - TupC[]|TupA[]|csv:Error csv1op3 = csv:parseLists(value, {skipLines: [2, 4]}); + TupC[]|TupA[]|csv:Error csv1op3 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op3, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - TupB[]|TupA[]|csv:Error csv1op4 = csv:parseLists(value, {skipLines: [2, 4]}); + TupB[]|TupA[]|csv:Error csv1op4 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op4, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - TupB[]|[boolean][]|csv:Error csv1op4_2 = csv:parseLists(value, {skipLines: [2, 4]}); + TupB[]|[boolean][]|csv:Error csv1op4_2 = csv:parseList(value, {skipLines: [2, 4]}); test:assertTrue(csv1op4_2 is csv:Error); test:assertEquals((csv1op4_2).message(), "The source value cannot convert in to the '(union_type_tests:TupB[]|[boolean][])'"); - TupA[]|TupB[]|csv:Error csv1op5 = csv:parseLists(value, {skipLines: [2, 4]}); + TupA[]|TupB[]|csv:Error csv1op5 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op5, [ [1, "string1", true, 2.234, 2.234, ()], [3, "string3", false, 1.23, 1.23, ()], [5, "string5", true, 3, 3.0, ()] ]); - [int][]|[string][]|csv:Error csv1op6 = csv:parseLists(value, {skipLines: [2, 4]}); + [int][]|[string][]|csv:Error csv1op6 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op6, [ [1], [3], [5] ]); - [string][]|[int][]|csv:Error csv1op7 = csv:parseLists(value, {skipLines: [2, 4]}); + [string][]|[int][]|csv:Error csv1op7 = csv:parseList(value, {skipLines: [2, 4]}); test:assertEquals(csv1op7, [ ["1"], ["3"], ["5"] ]); - [boolean...][]|[int...][]|csv:Error csv1op8 = csv:parseLists(value, {stringConversion: false}); + [boolean...][]|[int...][]|csv:Error csv1op8 = csv:parseList(value, {stringConversion: false}); test:assertTrue(csv1op8 is csv:Error); test:assertEquals((csv1op8).message(), "The source value cannot convert in to the '([boolean...][]|[int...][])'"); - [string...][]|[int...][]|csv:Error csv1op8_2 = csv:parseLists(value, {}); + [string...][]|[int...][]|csv:Error csv1op8_2 = csv:parseList(value, {}); test:assertEquals(csv1op8_2, value); - [int...][]|[string...][]|csv:Error csv1op9 = csv:parseLists(value, {}); + [int...][]|[string...][]|csv:Error csv1op9 = csv:parseList(value, {}); test:assertEquals(csv1op9, value); - [int, string...][]|[string, int...][]|csv:Error csv1op10 = csv:parseLists(value, {}); + [int, string...][]|[string, int...][]|csv:Error csv1op10 = csv:parseList(value, {}); test:assertEquals(csv1op10, [ [1, "string1", "true", "2.234", "2.234", "()"], [2, "string2", "false", "0", "0", "()"], @@ -1044,7 +1044,7 @@ function testParseToStringWithUnionExpectedTypes10() returns error? { [5, "string5", "true", "3", "3.0", "()"] ]); - [string, int...][]|[int, string...][]|csv:Error csv1op11 = csv:parseLists(value, {}); + [string, int...][]|[int, string...][]|csv:Error csv1op11 = csv:parseList(value, {}); test:assertEquals(csv1op11, [ [1, "string1", "true", "2.234", "2.234", "()"], [2, "string2", "false", "0", "0", "()"], @@ -1053,6 +1053,6 @@ function testParseToStringWithUnionExpectedTypes10() returns error? { [5, "string5", "true", "3", "3.0", "()"] ]); - [string, int...][]|[string, string...][]|csv:Error csv1op12 = csv:parseLists(value, {}); + [string, int...][]|[string, string...][]|csv:Error csv1op12 = csv:parseList(value, {}); test:assertEquals(csv1op12, value); } diff --git a/ballerina-tests/user-config-tests/tests/user_config_projection_tests.bal b/ballerina-tests/user-config-tests/tests/user_config_projection_tests.bal index cf2b6da..2ad8e88 100644 --- a/ballerina-tests/user-config-tests/tests/user_config_projection_tests.bal +++ b/ballerina-tests/user-config-tests/tests/user_config_projection_tests.bal @@ -184,79 +184,79 @@ function testCustomNameAnnotation() returns error? { @test:Config function testCustomNameAnnotation2() returns error? { - RecordWithCustomAnnotation[]|csv:Error cntr1 = csv:parseLists([["1", "3"]], {customHeaders: ["b", "c"]}); + RecordWithCustomAnnotation[]|csv:Error cntr1 = csv:parseList([["1", "3"]], {customHeaders: ["b", "c"]}); test:assertEquals(cntr1, [{b: 1, a: 3}]); - RecordWithCustomAnnotation[]|csv:Error cntr2 = csv:parseLists([["3", "1"]], {customHeaders: ["c", "b"]}); + RecordWithCustomAnnotation[]|csv:Error cntr2 = csv:parseList([["3", "1"]], {customHeaders: ["c", "b"]}); test:assertEquals(cntr2, [{b: 1, a: 3}]); - RecordWithCustomAnnotation[]|csv:Error cntr3 = csv:parseLists( + RecordWithCustomAnnotation[]|csv:Error cntr3 = csv:parseList( [["3", "3", "1", "cde"], ["3", "3", "1", "cde"]], {customHeaders: ["f", "c", "b", "e"]}); test:assertEquals(cntr3, [{b: 1, a: 3, f: 3, e: "cde"}, {b: 1, a: 3, f: 3, e: "cde"}]); - RecordWithCustomAnnotation2[]|csv:Error cntr4 = csv:parseLists([["1", "3"]], {customHeaders: ["d", "c"]}); + RecordWithCustomAnnotation2[]|csv:Error cntr4 = csv:parseList([["1", "3"]], {customHeaders: ["d", "c"]}); test:assertEquals(cntr4, [{b: 1, a: 3}]); - RecordWithCustomAnnotation2[]|csv:Error cntr5 = csv:parseLists([["3","1"]], {customHeaders: ["c", "d"]}); + RecordWithCustomAnnotation2[]|csv:Error cntr5 = csv:parseList([["3","1"]], {customHeaders: ["c", "d"]}); test:assertEquals(cntr5, [{b: 1, a: 3}]); - RecordWithCustomAnnotation2[]|csv:Error cntr6 = csv:parseLists( + RecordWithCustomAnnotation2[]|csv:Error cntr6 = csv:parseList( [["3", "3", "1", "cde"], ["3", "3", "1", "cde"]], {customHeaders: ["c", "f", "d", "e"]}); test:assertEquals(cntr6, [{b: 1, a: 3, f: 3, e: "cde"}, {b: 1, a: 3, f: 3, e: "cde"}]); - RecordWithCustomAnnotation2[]|csv:Error cntr7 = csv:parseLists([["3", "1"]], {customHeaders: ["a", "b"]}); + RecordWithCustomAnnotation2[]|csv:Error cntr7 = csv:parseList([["3", "1"]], {customHeaders: ["a", "b"]}); test:assertTrue(cntr7 is csv:Error); test:assertEquals((cntr7).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation2[]|csv:Error cntr8 = csv:parseLists([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); + RecordWithCustomAnnotation2[]|csv:Error cntr8 = csv:parseList([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); test:assertTrue(cntr8 is csv:Error); test:assertEquals((cntr8).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation3[]|csv:Error cntr9 = csv:parseLists([["1", "3"]], {customHeaders: ["d", "c"]}); + RecordWithCustomAnnotation3[]|csv:Error cntr9 = csv:parseList([["1", "3"]], {customHeaders: ["d", "c"]}); test:assertEquals(cntr9, [{b: 1, a: 3}]); - RecordWithCustomAnnotation3[]|csv:Error cntr10 = csv:parseLists([["3", "1"]], {customHeaders: ["c", "d"]}); + RecordWithCustomAnnotation3[]|csv:Error cntr10 = csv:parseList([["3", "1"]], {customHeaders: ["c", "d"]}); test:assertEquals(cntr10, [{b: 1, a: 3}]); - RecordWithCustomAnnotation3[]|csv:Error cntr11 = csv:parseLists( + RecordWithCustomAnnotation3[]|csv:Error cntr11 = csv:parseList( [["3", "3", "1", "cde"], ["3", "3", "1", "cde"]], {customHeaders: ["c", "f", "d", "e"]}); test:assertEquals(cntr11, [{b: 1, a: 3}, {b: 1, a: 3}]); - RecordWithCustomAnnotation3[]|csv:Error cntr12 = csv:parseLists([["3", "1"]], {customHeaders: ["a", "b"]}); + RecordWithCustomAnnotation3[]|csv:Error cntr12 = csv:parseList([["3", "1"]], {customHeaders: ["a", "b"]}); test:assertTrue(cntr12 is csv:Error); test:assertEquals((cntr12).message(), common:generateErrorMessageForInvalidHeaders(string `["3","1"]`, "user_config_tests:RecordWithCustomAnnotation3")); - RecordWithCustomAnnotation3[]|csv:Error cntr13 = csv:parseLists([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); + RecordWithCustomAnnotation3[]|csv:Error cntr13 = csv:parseList([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); test:assertTrue(cntr13 is csv:Error); test:assertEquals((cntr13).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation4[]|csv:Error cntr14 = csv:parseLists([["1", "3", "true"]], {customHeaders: ["d", "c", "z"]}); + RecordWithCustomAnnotation4[]|csv:Error cntr14 = csv:parseList([["1", "3", "true"]], {customHeaders: ["d", "c", "z"]}); test:assertEquals(cntr14, [{b: 1, a: 3, z: true}]); - RecordWithCustomAnnotation4[]|csv:Error cntr15 = csv:parseLists([["3", "1"]], {customHeaders: ["c", "d"]}); + RecordWithCustomAnnotation4[]|csv:Error cntr15 = csv:parseList([["3", "1"]], {customHeaders: ["c", "d"]}); test:assertEquals(cntr15, [{b: 1, a: 3}]); - RecordWithCustomAnnotation4[]|csv:Error cntr16 = csv:parseLists( + RecordWithCustomAnnotation4[]|csv:Error cntr16 = csv:parseList( [["3", "3", "1", "cde"], ["3", "3", "1", "cde"]], {customHeaders: ["c", "f", "d", "e"]}); test:assertEquals(cntr16, [{b: 1, a: 3}, {b: 1, a: 3}]); - RecordWithCustomAnnotation4[]|csv:Error cntr17 = csv:parseLists([["3", "1"]], {customHeaders: ["a", "b"]}); + RecordWithCustomAnnotation4[]|csv:Error cntr17 = csv:parseList([["3", "1"]], {customHeaders: ["a", "b"]}); test:assertTrue(cntr17 is csv:Error); test:assertEquals((cntr17).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation4[]|csv:Error cntr18 = csv:parseLists([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); + RecordWithCustomAnnotation4[]|csv:Error cntr18 = csv:parseList([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); test:assertTrue(cntr18 is csv:Error); test:assertEquals((cntr18).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation5[]|csv:Error cntr19 = csv:parseLists([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); + RecordWithCustomAnnotation5[]|csv:Error cntr19 = csv:parseList([["3", "1", "4", "5"]], {customHeaders: ["c", "d", "a", "b"]}); test:assertTrue(cntr19 is csv:Error); test:assertEquals((cntr19).message(), "Duplicate field found in record fields: 'a'"); - RecordWithCustomAnnotation5[]|csv:Error cntr20 = csv:parseLists( + RecordWithCustomAnnotation5[]|csv:Error cntr20 = csv:parseList( [["3", "1", "4"], ["3", "1", "4"]], {customHeaders: ["c", "d", "e"]}); test:assertEquals(cntr20, [{a: 3, b: 1, c: 4}, {a: 3, b: 1, c: 4}]); - RecordWithCustomAnnotation6[]|csv:Error cntr21 = csv:parseLists( + RecordWithCustomAnnotation6[]|csv:Error cntr21 = csv:parseList( [["3", "1", "4"], ["3", "1", "4"]], {customHeaders: ["c", "d", "a"]}); test:assertEquals(cntr21, [{a: 3, b: 1, c: 4}, {a: 3, b: 1, c: 4}]); } @@ -359,22 +359,22 @@ function testAbsentAsNilableConfig2() returns error? { test:assertTrue(cn4 is csv:Error); test:assertEquals((cn4).message(), common:generateErrorMessageForMissingRequiredField("g")); - record {|string a; int? g; int? h;|}[]|csv:Error cn5 = csv:parseLists([["a"], ["a"], ["a"]], {customHeaders: ["a"], + record {|string a; int? g; int? h;|}[]|csv:Error cn5 = csv:parseList([["a"], ["a"], ["a"]], {customHeaders: ["a"], allowDataProjection: {absentAsNilableType: true}, skipLines: [3] }); test:assertEquals(cn5, [{a: "a", g: (), h: ()}, {a: "a", g: (), h: ()}]); - record {|string a; int? g?;|}[]|csv:Error cn6 = csv:parseLists([["a"], ["a"], ["a"]], {customHeaders: ["a"], + record {|string a; int? g?;|}[]|csv:Error cn6 = csv:parseList([["a"], ["a"], ["a"]], {customHeaders: ["a"], allowDataProjection: {absentAsNilableType: true}, skipLines: [3] }); test:assertEquals(cn6, [{a: "a"}, {a: "a"}]); - record {|string a; int g?;|}[]|csv:Error cn7 = csv:parseLists([["a"], ["a"], ["b"]], {customHeaders: ["a"], + record {|string a; int g?;|}[]|csv:Error cn7 = csv:parseList([["a"], ["a"], ["b"]], {customHeaders: ["a"], allowDataProjection: {absentAsNilableType: true}, skipLines: [2] }); test:assertEquals(cn7, [{a: "a"}, {a: "b"}]); - record {|string a; int g;|}[]|csv:Error cn8 = csv:parseLists([["a"], ["a"], ["a"]], {customHeaders: ["a"], + record {|string a; int g;|}[]|csv:Error cn8 = csv:parseList([["a"], ["a"], ["a"]], {customHeaders: ["a"], allowDataProjection: {absentAsNilableType: true}, skipLines: [3] }); test:assertTrue(cn8 is csv:Error); diff --git a/ballerina-tests/user-config-tests/tests/user_config_with_parser_options_test.bal b/ballerina-tests/user-config-tests/tests/user_config_with_parser_options_test.bal index 23cd58e..895a90a 100644 --- a/ballerina-tests/user-config-tests/tests/user_config_with_parser_options_test.bal +++ b/ballerina-tests/user-config-tests/tests/user_config_with_parser_options_test.bal @@ -564,32 +564,32 @@ function testCustomHeaderOption() { test:assertTrue(bm3ba5 is csv:Error); test:assertEquals((bm3ba5).message(), "Invalid number of headers"); - record {}[]|csv:Error ct1br = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "b"]}); + record {}[]|csv:Error ct1br = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "b"]}); test:assertTrue(ct1br is csv:Error); test:assertEquals((ct1br).message(), "Invalid length for the headers"); - record {}[]|csv:Error ct1br2 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "b", "c", "d"]}); + record {}[]|csv:Error ct1br2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "b", "c", "d"]}); test:assertTrue(ct1br2 is csv:Error); test:assertEquals((ct1br2).message(), "Invalid length for the headers"); - record {}[]|csv:Error ct1br2_2 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "c", "b", "d"]}); + record {}[]|csv:Error ct1br2_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "c", "b", "d"]}); test:assertTrue(ct1br2_2 is csv:Error); test:assertEquals((ct1br2_2).message(), "Invalid length for the headers"); - record {}[]|csv:Error ct1br3 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: []}); + record {}[]|csv:Error ct1br3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: []}); test:assertTrue(ct1br3 is csv:Error); test:assertEquals((ct1br3).message(), "Invalid length for the headers"); - record {|string a; string b; string c;|}[]|csv:Error ct1br5 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"]}); + record {|string a; string b; string c;|}[]|csv:Error ct1br5 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"]}); test:assertTrue(ct1br5 is csv:Error); // TODO: Fix the error message test:assertEquals((ct1br5).message(), common:generateErrorMessageForMissingRequiredField("c")); - record {string a; string b; string c;}[]|csv:Error ct1br6 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"]}); + record {string a; string b; string c;}[]|csv:Error ct1br6 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"]}); test:assertTrue(ct1br6 is csv:Error); test:assertEquals((ct1br6).message(), common:generateErrorMessageForMissingRequiredField("c")); - record {string a; string b;}[]|csv:Error ct1br7 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], + record {string a; string b;}[]|csv:Error ct1br7 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], stringConversion: false }); test:assertEquals(ct1br7, [ @@ -597,7 +597,7 @@ function testCustomHeaderOption() { {a: "a", e: "1", b: "true"} ]); - record {|string a; string b;|}[]|csv:Error ct1br8 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], + record {|string a; string b;|}[]|csv:Error ct1br8 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], stringConversion: false }); test:assertEquals(ct1br8, [ @@ -605,7 +605,7 @@ function testCustomHeaderOption() { {a: "a", b: "true"} ]); - record {|string...;|}[]|csv:Error ct1br9 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], + record {|string...;|}[]|csv:Error ct1br9 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], {customHeaders: ["a", "e", "b"], stringConversion: false }); test:assertEquals(ct1br9, [ @@ -613,7 +613,7 @@ function testCustomHeaderOption() { {a: "a", b: "true", e: "1"} ]); - record {|string...;|}[]|csv:Error ct1br10 = csv:parseLists([["a", "1", "true"], ["a", "1", "true"]], { + record {|string...;|}[]|csv:Error ct1br10 = csv:parseList([["a", "1", "true"], ["a", "1", "true"]], { stringConversion: false }); test:assertEquals(ct1br10, [ @@ -962,36 +962,36 @@ function testSkipLineParameterWithOutputHeaderConfig() { result2 = csv:transform(csv1, {outputWithHeaders: true, skipLines: "2-3"}); test:assertEquals(result2, [["a", "b"], [1, 2], [4, 5]]); - result = csv:parseLists(csv2, {outputWithHeaders: true, skipLines: "2-3", customHeaders: ["a", "b"]}); + result = csv:parseList(csv2, {outputWithHeaders: true, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result, [{a: 1, b: 2}, {a: 4, b: 5}]); - result2 = csv:parseLists(csv2, {outputWithHeaders: true, skipLines: "2-3", customHeaders: ["a", "b"]}); + result2 = csv:parseList(csv2, {outputWithHeaders: true, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result2, [["a", "b"], [1, 2], [4, 5]]); - result = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3", customHeaders: ["a", "b"]}); + result = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result, [{a: 2, b: 3}]); - result2 = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3", customHeaders: ["a", "b"]}); + result2 = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result2, [["a", "b"], [2, 3]]); - result = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 2, skipLines: "2-3", customHeaders: ["a", "b"]}); + result = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 2, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result, [{a: 3, b: 4}]); - result2 = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 2, skipLines: "2-3", customHeaders: ["a", "b"]}); + result2 = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 2, skipLines: "2-3", customHeaders: ["a", "b"]}); test:assertEquals(result2, [["a", "b"], [3, 4]]); - result = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3"}); + result = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3"}); test:assertEquals(result, [{'1: 2, '2: 3}]); - result2 = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3"}); + result2 = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 1, skipLines: "2-3"}); test:assertEquals(result2, [[1, 2], [2, 3]]); - result2 = csv:parseLists(csv2, {outputWithHeaders: false, headerRows: 1, skipLines: "2-3"}); + result2 = csv:parseList(csv2, {outputWithHeaders: false, headerRows: 1, skipLines: "2-3"}); test:assertEquals(result2, [[2, 3]]); - result = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b"], skipLines: "2-3"}); + result = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b"], skipLines: "2-3"}); test:assertEquals(result, [{a: 3, b: 4}]); - result2 = csv:parseLists(csv2, {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b"], skipLines: "2-3"}); + result2 = csv:parseList(csv2, {outputWithHeaders: true, headerRows: 2, customHeaders: ["a", "b"], skipLines: "2-3"}); test:assertEquals(result2, [["a", "b"], [3, 4]]); } diff --git a/ballerina/Package.md b/ballerina/Package.md index 1af609a..5de4753 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -82,7 +82,7 @@ type Book record { public function main() returns error? { string[][] bookArray = [["Clean Code","2008"],["Clean Architecture","2017"]]; - Book[] author = check csv:parseLists(bookArray, customHeaders = ["name", "year"]); + Book[] author = check csv:parseList(bookArray, customHeaders = ["name", "year"]); io:println(author); } ``` diff --git a/ballerina/csv_api.bal b/ballerina/csv_api.bal index ddc749d..acf0012 100644 --- a/ballerina/csv_api.bal +++ b/ballerina/csv_api.bal @@ -16,19 +16,19 @@ import ballerina/jballerina.java; -public isolated function parseString(string s, ParseOptions options = {}, typedesc t = <>) +public isolated function parseString(string csvString, ParseOptions options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; -public isolated function parseBytes(byte[] s, ParseOptions options = {}, typedesc t = <>) +public isolated function parseBytes(byte[] csvBytes, ParseOptions options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; -public isolated function parseStream(stream s, +public isolated function parseStream(stream csvByteStream, ParseOptions options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; -public isolated function transform(record{}[] s, +public isolated function transform(record{}[] csvRecords, TransformOptions options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; -public isolated function parseLists(string[][] s, ParseListsOptions options = {}, typedesc t = <>) +public isolated function parseList(string[][] csvList, ParseListOptions options = {}, typedesc t = <>) returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external; diff --git a/ballerina/types.bal b/ballerina/types.bal index e2dba0d..4ce205d 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -29,7 +29,8 @@ public type Options record { # Lines to skip during processing, specified either as an array of integers or a string. int[]|string skipLines = []; # If `true`, enables validation of constraints during processing. - boolean enableConstraintValidation = true; # If `true`, the resulted CSV contains the headers as the first row. + boolean enableConstraintValidation = true; + # If `true`, the resulted CSV contains the headers as the first row. # This field is only acceptable if the expected type is subset of `anydata[][]` boolean outputWithHeaders = false; }; @@ -60,7 +61,7 @@ public type ParseOptions record {| |}; # Represents options for treating a list as a record. -public type ParseListsOptions record {| +public type ParseListOptions record {| *Options; # If `true`, enables conversion of strings during processing. boolean stringConversion = true; diff --git a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_1/main.bal b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_1/main.bal index 8943e55..4adb715 100644 --- a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_1/main.bal +++ b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_1/main.bal @@ -12,21 +12,21 @@ public function main() returns error? { A _ = check csv:parseBytes([1,2,3], {}); record{}[]|[record{}, record{}, record{}, record{}] _ = check csv:parseBytes([1,2,3], {}); int[][]|[[int, string], [int, string]] _ = check csv:transform([{}], {}); - [[int, string], [int, string]] _ = check csv:parseLists([], {}); + [[int, string], [int, string]] _ = check csv:parseList([], {}); [record{}, record{}, record{}, record{}] _ = check csv:transform([{}], {}); - [record{}, record{}, record{}, record{}] _ = check csv:parseLists([], {}); - record{record{} a;}[] _ = check csv:parseLists([], {}); - record{int[] a;}[] _ = check csv:parseLists([], {}); - record{[int...] a;}[] _ = check csv:parseLists([], {}); - record{[int...] a;}[] _ = check csv:parseLists([], {}); - record{record{} a;}[] _ = check csv:parseLists([], {}); - record{xml a; regexp:RegExp b;}[] _ = check csv:parseLists([], {}); - [xml, xml][] _ = check csv:parseLists([], {}); - [regexp:RegExp, xml, int[]][] _ = check csv:parseLists([], {}); - [regexp:RegExp, xml, int[]][]|int[][] _ = check csv:parseLists([], {}); - int[][]|[regexp:RegExp, xml, int[]][] _ = check csv:parseLists([], {}); - int[][]|[record{}|regexp:RegExp][] _ = check csv:parseLists([], {}); - record{}[]|int[][] _ = check csv:parseLists([], {}); - record{}[2] _ = check csv:parseLists([], {}); - int[3][2] _ = check csv:parseLists([], {}); + [record{}, record{}, record{}, record{}] _ = check csv:parseList([], {}); + record{record{} a;}[] _ = check csv:parseList([], {}); + record{int[] a;}[] _ = check csv:parseList([], {}); + record{[int...] a;}[] _ = check csv:parseList([], {}); + record{[int...] a;}[] _ = check csv:parseList([], {}); + record{record{} a;}[] _ = check csv:parseList([], {}); + record{xml a; regexp:RegExp b;}[] _ = check csv:parseList([], {}); + [xml, xml][] _ = check csv:parseList([], {}); + [regexp:RegExp, xml, int[]][] _ = check csv:parseList([], {}); + [regexp:RegExp, xml, int[]][]|int[][] _ = check csv:parseList([], {}); + int[][]|[regexp:RegExp, xml, int[]][] _ = check csv:parseList([], {}); + int[][]|[record{}|regexp:RegExp][] _ = check csv:parseList([], {}); + record{}[]|int[][] _ = check csv:parseList([], {}); + record{}[2] _ = check csv:parseList([], {}); + int[3][2] _ = check csv:parseList([], {}); } diff --git a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_4/main.bal b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_4/main.bal index bfeeb9f..08aeee3 100644 --- a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_4/main.bal +++ b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_4/main.bal @@ -10,8 +10,8 @@ stream s = ( [[1, 2, 3, 4, 5]]).toStream(); A val5 = check csv:parseBytes([1,2,3], {}); record{}[]|[record{}, record{}, record{}, record{}] val6 = check csv:parseBytes([1,2,3], {}); int[][]|[[int, string], [int, string]] val7 = check csv:transform([{}], {}); -[[int, string], [int, string]] val8 = check csv:parseLists([], {}); +[[int, string], [int, string]] val8 = check csv:parseList([], {}); [record{}, record{}, record{}, record{}] val9 = check csv:transform([{}], {}); -[record{}, record{}, record{}, record{}] val10 = check csv:parseLists([], {}); -record{}[2] val11 = check csv:parseLists([], {}); -int[3][2] val12 = check csv:parseLists([], {}); +[record{}, record{}, record{}, record{}] val10 = check csv:parseList([], {}); +record{}[2] val11 = check csv:parseList([], {}); +int[3][2] val12 = check csv:parseList([], {}); diff --git a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_6/main.bal b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_6/main.bal index b5ec5a8..0d1fa56 100644 --- a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_6/main.bal +++ b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_6/main.bal @@ -16,9 +16,9 @@ public function test() returns error? { A val5 = check csv:parseBytes([1,2,3], {}); record{}[]|[record{}, record{}, record{}, record{}] val6 = check csv:parseBytes([1,2,3], {}); int[][]|[[int, string], [int, string]] val7 = check csv:transform([{}], {}); - [[int, string], [int, string]] val8 = check csv:parseLists([], {}); + [[int, string], [int, string]] val8 = check csv:parseList([], {}); [record{}, record{}, record{}, record{}] val9 = check csv:transform([{}], {}); - [record{}, record{}, record{}, record{}] val10 = check csv:parseLists([], {}); - record{}[2] val11 = check csv:parseLists([], {}); - int[3][2] val12 = check csv:parseLists([], {}); + [record{}, record{}, record{}, record{}] val10 = check csv:parseList([], {}); + record{}[2] val11 = check csv:parseList([], {}); + int[3][2] val12 = check csv:parseList([], {}); } diff --git a/compiler-plugin/src/main/java/io/ballerina/lib/data/csvdata/compiler/Constants.java b/compiler-plugin/src/main/java/io/ballerina/lib/data/csvdata/compiler/Constants.java index 348a97f..c1cb305 100644 --- a/compiler-plugin/src/main/java/io/ballerina/lib/data/csvdata/compiler/Constants.java +++ b/compiler-plugin/src/main/java/io/ballerina/lib/data/csvdata/compiler/Constants.java @@ -28,7 +28,7 @@ public final class Constants { static final String PARSE_BYTES = "parseBytes"; static final String PARSE_STREAM = "parseStream"; static final String TRANSFORM = "transform"; - static final String PARSE_LISTS = "parseLists"; + static final String PARSE_LISTS = "parseList"; static final String NAME = "Name"; static final String CSVDATA = "csv"; static final String BALLERINA = "ballerina"; diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java index f7811c1..49fb17c 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java @@ -96,9 +96,9 @@ public static Object transform(BArray csv, BMap options, BTyped return DiagnosticLog.getCsvError(e.getMessage()); } } - public static Object parseLists(BArray csv, BMap options, BTypedesc type) { + public static Object parseList(BArray csv, BMap options, BTypedesc type) { try { - return CsvTraversal.traverse(csv, CsvConfig.createParseListsOptions(options), type); + return CsvTraversal.traverse(csv, CsvConfig.createParseListOptions(options), type); } catch (Exception e) { return DiagnosticLog.getCsvError(e.getMessage()); }