Skip to content

Commit

Permalink
Merge pull request #14 from SasinduDilshara/development-2
Browse files Browse the repository at this point in the history
Add more tests to locale config
  • Loading branch information
SasinduDilshara authored Jul 31, 2024
2 parents f81a973 + 68a0260 commit cc73513
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 218 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*.zip
*.tar.gz
*.rar
*.deb

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.csv
hs_err_pid*
Expand Down
4 changes: 2 additions & 2 deletions ballerina-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {

import org.apache.tools.ant.taskdefs.condition.Os

description = 'Ballerina - HTTP/WS Ballerina Tests'
description = 'Ballerina - CSV data module Ballerina Tests'

def packageName = "data.csv"
def packageOrg = "ballerina"
Expand All @@ -29,7 +29,7 @@ def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/res
def testCommonTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/CsvTestCommon.toml")
def ballerinaDist = "${project.rootDir}/target/ballerina-runtime"
def distributionBinPath = "${ballerinaDist}/bin"
def testCoverageParam = "--code-coverage --coverage-format=xml --includes=io.ballerina.lib.data.*:ballerina.*"
def testCoverageParam = "--code-coverage --coverage-format=xml --includes=io.ballerina.lib.data.csvdata.*:ballerina.*"
def testPackages = ["user-config-tests", "type-compatible-tests", "parse-string-array-types-tests", "unicode-tests", "constraint-validation-tests",
"parse-list-types-tests", "parse-record-types-tests", "parse-string-record-types-tests", "union-type-tests"]
def testCommonPackage = "csv-commons"
Expand Down
11 changes: 0 additions & 11 deletions ballerina-tests/constraint-validation-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/csv-commons/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/parse-list-types-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/parse-record-types-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/parse-string-array-types-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/parse-string-record-types-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/type-compatible-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/unicode-tests/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions ballerina-tests/union-type-tests/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/data.csv;
import ballerina/test;

Expand All @@ -22,25 +21,25 @@ function testIntersectionExpectedTypes() returns error? {
(int[] & readonly)[]|csv:Error a = csv:parseStringToList(string `a,b
1,2
4,5`);
test:assertTrue(a is (int[] & readonly)[]);
test:assertTrue(a is (int[] & readonly)[]);
test:assertEquals(a, [[1, 2], [4, 5]]);

([string, string])[] & readonly|csv:Error a2 = csv:parseStringToList(string `a,b
a,a
c,c`);
test:assertTrue(a2 is [string, string][] & readonly);
test:assertTrue(a2 is [string, string][] & readonly);
test:assertEquals(a2, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a3 = csv:parseStringToRecord(string `a,b
(record {int a; string b;} & readonly)[]|csv:Error a3 = csv:parseStringToRecord(string `a,b
1,2
4,5`);
test:assertTrue(a3 is (record{int a; string b;} & readonly)[]);
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:parseStringToRecord(string `a,b
record {|string...;|}[] & readonly|csv:Error a4 = csv:parseStringToRecord(string `a,b
a,a
c,c`);
test:assertTrue(a4 is record{|string...;|}[] & readonly);
test:assertTrue(a4 is record {|string...;|}[] & readonly);
test:assertEquals(a4, [{a: "a", b: "a"}, {a: "c", b: "c"}]);

([int] & readonly)[]|csv:Error a5 = csv:parseStringToList(string `a,b
Expand All @@ -55,10 +54,10 @@ function testIntersectionExpectedTypes() returns error? {
test:assertTrue(a6 is [string, string][] & readonly);
test:assertEquals(a6, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a7 = csv:parseStringToRecord(string `a,b
(record {int a; string b;} & readonly)[]|csv:Error a7 = csv:parseStringToRecord(string `a,b
1,2
4,5`);
test:assertTrue(a7 is record{int a; string b;}[] & readonly);
test:assertTrue(a7 is record {int a; string b;}[] & readonly);
test:assertEquals(a7, [{a: 1, b: "2"}, {a: 4, b: "5"}]);

map<string>[] & readonly|csv:Error a8 = csv:parseStringToRecord(string `a,b
Expand All @@ -73,7 +72,7 @@ function testIntersectionExpectedTypes() returns error? {
test:assertTrue(a9 is (((int[] & readonly)|([string, string] & readonly)) & readonly)[]);
test:assertEquals(a9, [[1, 2], ["a", "a"]]);

((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[]
((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[]
& readonly|csv:Error a10 = csv:parseStringToRecord(string `a,b
a,a
1,2`);
Expand All @@ -84,19 +83,19 @@ function testIntersectionExpectedTypes() returns error? {
@test:Config
function testIntersectionExpectedTypes2() returns error? {
(int[] & readonly)[]|csv:Error a = csv:parseRecordAsListType([{"a": 1, "b": 2}, {"a": 4, "b": 5}], ["a", "b"], {});
test:assertTrue(a is (int[] & readonly)[]);
test:assertTrue(a is (int[] & readonly)[]);
test:assertEquals(a, [[1, 2], [4, 5]]);

([string, string])[] & readonly|csv:Error a2 = csv:parseRecordAsListType([{"a": "a", "b": "a"}, {"a": "c", "b": "c"}], ["a", "b"], {});
test:assertTrue(a2 is [string, string][] & readonly);
test:assertTrue(a2 is [string, string][] & readonly);
test:assertEquals(a2, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a3 = csv:parseRecordAsRecordType([{"a": 1, "b": "2"}, {"a": 4, "b": "5"}], {});
test:assertTrue(a3 is (record{int a; string b;} & readonly)[]);
(record {int a; string b;} & readonly)[]|csv:Error a3 = csv:parseRecordAsRecordType([{"a": 1, "b": "2"}, {"a": 4, "b": "5"}], {});
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:parseRecordAsRecordType([{"a": "a", "b": "a"}, {"a": "c", "b": "c"}], {});
test:assertTrue(a4 is record{|string...;|}[] & readonly);
record {|string...;|}[] & readonly|csv:Error a4 = csv:parseRecordAsRecordType([{"a": "a", "b": "a"}, {"a": "c", "b": "c"}], {});
test:assertTrue(a4 is record {|string...;|}[] & readonly);
test:assertEquals(a4, [{a: "a", b: "a"}, {a: "c", b: "c"}]);

([int] & readonly)[]|csv:Error a5 = csv:parseRecordAsListType([{"a": 1, "b": 2}, {"a": 4, "b": 5}], ["a", "b"], {});
Expand All @@ -107,8 +106,8 @@ function testIntersectionExpectedTypes2() returns error? {
test:assertTrue(a6 is [string, string][] & readonly);
test:assertEquals(a6, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a7 = csv:parseRecordAsRecordType([{"a": 1, "b": "2"}, {"a": 4, "b": "5"}], {});
test:assertTrue(a7 is record{int a; string b;}[] & readonly);
(record {int a; string b;} & readonly)[]|csv:Error a7 = csv:parseRecordAsRecordType([{"a": 1, "b": "2"}, {"a": 4, "b": "5"}], {});
test:assertTrue(a7 is record {int a; string b;}[] & readonly);
test:assertEquals(a7, [{a: 1, b: "2"}, {a: 4, b: "5"}]);

map<string>[] & readonly|csv:Error a8 = csv:parseRecordAsRecordType([{"a": "a", "b": "a"}, {"a": "c", "b": "c"}], {});
Expand All @@ -119,7 +118,7 @@ function testIntersectionExpectedTypes2() returns error? {
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))[]
((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[]
& readonly|csv:Error a10 = csv:parseRecordAsRecordType([{"a": "a", "b": "a"}, {"a": 1, "b": 2}], {});
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}]);
Expand All @@ -128,19 +127,19 @@ function testIntersectionExpectedTypes2() returns error? {
@test:Config
function testIntersectionExpectedTypes3() returns error? {
(int[] & readonly)[]|csv:Error a = csv:parseListAsListType([["1", "2"], ["4", "5"]], {});
test:assertTrue(a is (int[] & readonly)[]);
test:assertTrue(a is (int[] & readonly)[]);
test:assertEquals(a, [[1, 2], [4, 5]]);

([string, string])[] & readonly|csv:Error a2 = csv:parseListAsListType([["a", "a"], ["c", "c"]], {});
test:assertTrue(a2 is [string, string][] & readonly);
test:assertTrue(a2 is [string, string][] & readonly);
test:assertEquals(a2, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a3 = csv:parseListAsRecordType([["1", "2"], ["4", "5"]], ["a", "b"], {});
test:assertTrue(a3 is (record{int a; string b;} & readonly)[]);
(record {int a; string b;} & readonly)[]|csv:Error a3 = csv:parseListAsRecordType([["1", "2"], ["4", "5"]], ["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:parseListAsRecordType([["a", "a"], ["c", "c"]], ["a", "b"], {});
test:assertTrue(a4 is record{|string...;|}[] & readonly);
record {|string...;|}[] & readonly|csv:Error a4 = csv:parseListAsRecordType([["a", "a"], ["c", "c"]], ["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:parseListAsListType([["1", "2"], ["4", "5"]], {});
Expand All @@ -151,8 +150,8 @@ function testIntersectionExpectedTypes3() returns error? {
test:assertTrue(a6 is [string, string][] & readonly);
test:assertEquals(a6, [["a", "a"], ["c", "c"]]);

(record{int a; string b;} & readonly)[]|csv:Error a7 = csv:parseListAsRecordType([["1", "2"], ["4", "5"]], ["a", "b"], {});
test:assertTrue(a7 is record{int a; string b;}[] & readonly);
(record {int a; string b;} & readonly)[]|csv:Error a7 = csv:parseListAsRecordType([["1", "2"], ["4", "5"]], ["a", "b"], {});
test:assertTrue(a7 is record {int a; string b;}[] & readonly);
test:assertEquals(a7, [{a: 1, b: "2"}, {a: 4, b: "5"}]);

map<string>[] & readonly|csv:Error a8 = csv:parseListAsRecordType([["a", "a"], ["c", "c"]], ["a", "b"], {});
Expand All @@ -163,12 +162,12 @@ function testIntersectionExpectedTypes3() returns error? {
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))[]
((record {string a; string b;} & readonly)|(record {int a; int b;} & readonly))[]
& readonly|csv:Error a10 = csv:parseListAsRecordType([["a", "a"], ["1", "2"]], ["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))[]
((record {int a; int b;} & readonly)|(record {string a; string b;} & readonly))[]
& readonly|csv:Error a11 = csv:parseListAsRecordType([["a", "a"], ["1", "2"]], ["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}]);
Expand Down
11 changes: 0 additions & 11 deletions ballerina-tests/user-config-tests/.gitignore

This file was deleted.

Loading

0 comments on commit cc73513

Please sign in to comment.