diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml
index 291054d..77a583e 100644
--- a/.github/workflows/build-with-bal-test-graalvm.yml
+++ b/.github/workflows/build-with-bal-test-graalvm.yml
@@ -35,3 +35,5 @@ jobs:
lang_tag: ${{ inputs.lang_tag }}
lang_version: ${{ inputs.lang_version }}
native_image_options: '-J-Xmx7G ${{ inputs.native_image_options }}'
+ # TODO : Enable after fixing this issue : https://github.com/ballerina-platform/ballerina-lang/issues/38882
+ additional_windows_build_flags: '-x test'
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 9454d4e..0edaae9 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -12,5 +12,5 @@ jobs:
uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main
secrets: inherit
with:
- package-name: data.jsondata
+ package-name: data.csv
package-org: ballerina
diff --git a/.github/workflows/stale_check.yml b/.github/workflows/stale_check.yml
new file mode 100644
index 0000000..8763360
--- /dev/null
+++ b/.github/workflows/stale_check.yml
@@ -0,0 +1,19 @@
+name: 'Close stale pull requests'
+
+on:
+ schedule:
+ - cron: '30 19 * * *'
+ workflow_dispatch:
+
+jobs:
+ stale:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/stale@v3
+ with:
+ stale-pr-message: 'This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the `stale` label is removed or commented.'
+ close-pr-message: 'Closed PR due to inactivity for more than 18 days.'
+ days-before-pr-stale: 15
+ days-before-pr-close: 3
+ days-before-issue-stale: -1
+ days-before-issue-close: -1
diff --git a/.gitignore b/.gitignore
index 1d2a7ee..38d72e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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*
diff --git a/README.md b/README.md
index ba9bc60..4236cc1 100644
--- a/README.md
+++ b/README.md
@@ -1,407 +1,160 @@
-# Ballerina CSV Data Library
+# Ballerina CSV Data Library
-The Ballerina CSV Data Library is a comprehensive toolkit designed to facilitate the handling and manipulation of CSV data within Ballerina applications. It streamlines the process of converting CSV data to native Ballerina data types, enabling developers to work with CSV content seamlessly and efficiently.
+[![Build](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/build-timestamped-master.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/build-timestamped-master.yml)
+[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerina-data.csv/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerina-data.csv)
+[![Trivy](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/trivy-scan.yml)
+[![GraalVM Check](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerina-data.csv/actions/workflows/build-with-bal-test-graalvm.yml)
+[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerina-data.csv.svg)](https://github.com/ballerina-platform/module-ballerina-data.csv/commits/master)
+[![Github issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-standard-library/module/data.csv.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-standard-library/labels/module%2Fdata.csv)
-This library is the refined successor of the `ballerina/csvdata` module, incorporating enhanced functionalities and improved performance.
+The Ballerina CSV Data Library is a comprehensive toolkit designed to facilitate the handling and manipulation of CSV data within Ballerina applications. It streamlines the process of converting CSV data to native Ballerina data types, enabling developers to work with CSV content seamlessly and efficiently.
## Features
-- **Versatile CSV Data Input**: Accept CSV data as a csv, a string, byte array, or a stream and convert it into a Record value.
-- **CSV to Record Value Conversion**: Transform CSV data into Ballerina records with ease in compliance with OpenAPI 3 standards.
-- **Projection Support**: Perform selective conversion of CSV data subsets into Record values through projection.
+- **Versatile CSV Data Input**: Accept CSV data as a string, byte array, or a stream and convert it into a subtype of ballerina records or lists.
+- **CSV to anydata Value transformation**: Transform CSV data into expected type which is subtype of ballerina record arrays or anydata arrays.
+- **Projection Support**: Perform selective conversion of CSV data subsets into ballerina record array or anydata array values through projection.
## Usage
-### Converting an CSV value to a Record value
+### Converting CSV string to a record array
-To convert an CSV value to a Record value, you can utilize the `fromCsvWithType` function provided by the library. The example below showcases the transformation of an CSV value into a Record value.
+To convert a CSV string into a record array value, you can use the `parseString` function from the library. The following example demonstrates how to transform a CSV document into an array of records.
```ballerina
import ballerina/data.csv;
import ballerina/io;
-public function main() returns error? {
- csv data = csv `
- 0
- string
- string
- `;
+type Book record {
+ string name;
+ string author;
+ int year;
+};
- Book book = check csvdata:fromCsvWithType(data);
- io:println(book);
+public function main() returns error? {
+ string csvString = string `name,author,year
+ Clean Code,Robert C. Martin,2008
+ The Pragmatic Programmer,Andrew Hunt and David Thomas,1999`;
+
+ Book[] books = check csv:parseString(csvString);
+ foreach var book in books {
+ io:println(book);
+ }
}
-
-type Book record {|
- int id;
- string title;
- string author;
-|};
```
-### Converting an external CSV document to a Record value
+### Converting external CSV document to a record value
-For transforming CSV content from an external source into a Record value, the `fromCsvStringWithType` function can be used. This external source can be in the form of a string or a byte array/byte stream that houses the CSV data. This is commonly extracted from files or network sockets. The example below demonstrates the conversion of an CSV value from an external source into a Record value.
+For transforming CSV content from an external source into a record value, the `parseString`, `parseBytes` and `parseStream` functions can be used. This external source can be in the form of a string or a byte array/byte block stream that houses the CSV data. This is commonly extracted from files or network sockets. The example below demonstrates the conversion of an CSV value from an external source into a record value.
```ballerina
import ballerina/data.csv;
import ballerina/io;
+type Book record {
+ string name;
+ string author;
+ int year;
+};
+
public function main() returns error? {
+ // Read the CSV content as a string
string csvContent = check io:fileReadString("path/to/file.csv");
- Book book = check csvdata:fromCsvStringWithType(csvContent);
+ Book[] book = check csv:parseString(csvContent);
io:println(book);
-}
-
-type Book record {|
- int id;
- string title;
- string author;
-|};
-```
-
-Make sure to handle possible errors that may arise during the file reading or CSV to record conversion process. The `check` keyword is utilized to handle these errors, but more sophisticated error handling can be implemented as per your requirements.
-## CSV to Record Canonical Representation
-
-The translation of CSV to a Record representation is a fundamental feature of the library. It facilitates a structured and type-safe approach to handling CSV data within Ballerina applications.
-
-Take for instance the following CSV snippet:
-
-```csv
-
- 0
- string
- string
-
-```
-
-CSV data is inherently hierarchical, forming a tree structure. In the given example, the root element is `book`, which encompasses three child elements: `id`, `title`, and `author`. The `id` element harbors a numeric value `0`, whereas both the `title` and `author` elements contain string values.
-
-A straightforward record representation of the above CSV data is:
-
-```ballerina
-type Book record {|
- int id;
- string title;
- string author;
-|};
+ // Read the CSV content as a stream
+ stream csvStream = check io:fileReadBlocksAsStream("path/to/file.csv");
+ Book[] book2 = check csv:parseStream(csvStream);
+ io:println(book2);
+}
```
-In this representation, the CSV data is efficiently translated into a record value. The `book` element is mapped to a record of type `Book`, and the child elements `id`, `title`, and `author` are converted into record fields of types `int` and `string` correspondingly.
-
-This record type definition can be further refined through annotations. Moreover, utilizing open and closed records grants control over the translation process, which is elaborated in subsequent sections.
-
-### CSV Element Names
-
-The name of the CSV element serves as the name of the record field, altered to fit a valid Ballerina identifier. Notably, the record field name corresponds to the local name of the CSV element, with any namespace prefixes being disregarded.
+Make sure to handle possible errors that may arise during the file reading or CSV to record/array conversion process. The `check` keyword is utilized to handle these errors, but more sophisticated error handling can be implemented as per your requirements.
-Consider the CSV snippet:
+## CSV to record array/anydata array of array representation
-```csv
-
- 0
- string
- string
-
-```
-
-The canonical representation of the above CSV as a Ballerina record is:
-
-```ballerina
-type Book record {|
- int id;
- string 'title\-name';
- string 'author\-name';
-|};
-```
-
-Observe how the CSV element names `title-name` and `author-name` are represented using delimited identifiers in Ballerina; the `-` characters in the CSV element names are escaped using the `\` character.
-
-Moreover, the `@Name` annotation can be utilized to explicitly specify the name of the record field, providing control over the translation process:
+The CSV Object can be represented as a value of type `record/map array` or `string array of array` in Ballerina, which facilitates a structured and type-safe approach to handling CSV data.
+The conversion of CSV data to subtype of `record array` or `anydata array of array` representation is a fundamental feature of the library.
```ballerina
import ballerina/data.csv;
+import ballerina/io;
-type Book record {|
- int id;
- @csvdata:Name { value: "title-name" }
- string title;
- @csvdata:Name { value: "author-name" }
- string author;
-|};
-```
-
-### CSV Attributes
-
-Similarly to CSV elements, CSV attributes are also represented into record fields within the corresponding parent Record type. The name of the CSV attribute is converted into the name of the record field, ensuring it is a valid Ballerina identifier. It is crucial to emphasize that the record field name aligns with the local name of the CSV attribute, and any namespace prefixes are ignored.
-
-Consider the following CSV snippet:
-
-```csv
-
- 0
- string
- string
-
-```
-
-The canonical representation of the above CSV as a Ballerina record is:
-
-```ballerina
-type Book record {|
- string lang;
- decimal price;
- int id;
- string title;
- string author;
-|};
-```
-
-Additionally the `@Attribute` annotation can be utilized to explicitly specify the name of the record field, providing control over the translation process.
-
-### Child Elements
-
-Child elements are mapped to record fields, with the type reflecting that of the corresponding child element.
-
-Examine the CSV snippet below:
-
-```csv
-
- 0
- string
-
- string
- string
-
-
-```
-
-The canonical representation of the above CSV as a Ballerina record is:
-
-```ballerina
-type Book record {|
- int id;
- string title;
- Author author;
-|};
-
-type Author record {|
+type Book record {
string name;
- string country;
-|};
-```
-
-In this transformation, child elements, like the `author` element containing its own sub-elements, are converted into nested records. This maintains the hierarchical structure of the CSV data within the Ballerina type system, enabling intuitive and type-safe data manipulation.
-
-Alternatively, inline type definitions offer a compact method for representing child elements as records within their parent record. This approach is particularly beneficial when the child record does not require reuse elsewhere and is unique to its parent record.
-
-Consider the subsequent Ballerina record definition, which employs inline type definition for the `author` field:
-
-```ballerina
-type Book record {|
- int id;
- string title;
- record {|
- string name;
- string country;
- |} author;
-|};
-```
-
-### CSV Text Content
-
-The transformation of CSV text content into record fields typically involves types like `string`, `boolean`, `int`, `float`, or `decimal`, depending on the textual content. For numeric values where type information is not explicitly defined, the default conversion type is `decimal`. Conversely, for non-numeric content, the default type is `string`.
-
-Consider the CSV snippet below:
+ int year;
+};
-```csv
-
- 0
- string
- string
- true
- 10.5
-
-```
-
-The translation into a Ballerina record would be as follows:
-
-```ballerina
-type Book record {|
- int id;
- string title;
- string author;
- boolean available;
- decimal price;
-|};
-```
-
-In scenarios where the parent CSV element of text content also includes attributes, the CSV text content can be represented by a `string` type field named `#content` within a record type, with the attributes being mapped to their respective fields.
-
-For instance, examine this CSV:
-
-```csv
-
- 0
- string
- 10.5
-
-```
-
-The canonical translation of CSV to a Ballerina record is as such:
-
-```ballerina
-type Book record {|
- int id;
- Title title;
- decimal price;
-|};
-
-type Title record {|
- string \#content;
- string lang;
-|};
-```
-
-Modifications to the default behavior for converting numerical values can be achieved by providing `Options` mappings to the respective functions. This enables developers to choose specific data types and exert finer control over the conversion process.
-
-### CSV Namespaces
-
-CSV namespaces are accommodated by the library, supporting the translation of CSV data that contains namespace prefixes. However, the presence of CSV namespaces is not mandatory, and the library is capable of processing CSV data without namespaces. Should namespaces be present, they will be utilized to resolve the names of CSV elements and attributes.
-
-It's important to note that, unlike in the `csvdata` module, the namespace prefixes do not reflect in the record field names, as the record field names align with the local names of the CSV elements.
-
-Examine the CSV snippet below with default namespaces:
-
-```csv
-
- 0
- string
- string
-
-```
-
-The translation into a Ballerina record would be:
+public function main() returns error? {
+ string[][] bookArray = [["Clean Code","2008"],["Clean Architecture","2017"]];
+ Book[] bookRecords = [{name: "Clean Code", year: 2008}, {name: "Clean Architecture", year: 2017}];
-```ballerina
-type Book record {|
- int id;
- string title;
- string author;
-|};
-```
+ // Parse and output a record array from a source of string array of arrays.
+ Book[] books = check csv:parseList(bookArray, {customHeaders: ["name", "year"]});
+ io:println(books);
-Incorporating namespace validation yields:
+ // Parse and output a tuple array from a source of string array of arrays.
+ [string, int][] books2 = check csv:parseList(bookArray, {customHeaders: ["name", "year"]});
+ io:println(books2);
-```ballerina
-import ballerina/data.csv;
-
-@csvdata:Namespace {
- uri: "http://example.com/book"
+ // Transform CSV records to a string array of arrays.
+ [string, int][] books3 = check csv:transform(bookRecords);
+ io:println(books3);
}
-type Book record {|
- int id;
- string title;
- string author;
-|};
```
-Here is the same CSV snippet with a namespace prefix:
+### Controlling the CSV value to record array conversion
-```csv
-
- 0
- string
- string
-
-```
-
-The translation into a Ballerina record would be:
+The library allows for selective conversion of CSV into closed record arrays. This is beneficial when the CSV data contains headers that are not necessary to be transformed into record fields.
```ballerina
import ballerina/data.csv;
+import ballerina/io;
-@csvdata:Namespace {
- uri: "http://example.com/book",
- prefix: "bk"
-}
type Book record {|
- int id;
- string title;
+ string name;
string author;
|};
-```
-
-In these examples, the CSV namespaces are appropriately acknowledged, ensuring the integrity of the CSV structure within the Ballerina records.
-
-### Working with Arrays
-
-The library is equipped to handle the transformation of CSV data containing arrays into Ballerina records.
-
-Take the following CSV snippet as an example:
-
-```csv
-
- 0
- string
- string
- string
- string
-
-```
-
-The canonical representation of this CSV as a Ballerina record is:
-
-```ballerina
-type Book record {|
- int id;
- string title;
- string[] author;
-|};
-```
-
-### Controlling Which Elements to Convert
-
-The library allows for selective conversion of CSV elements into records through the use of rest fields. This is beneficial when the CSV data contains elements that are not necessary to be transformed into record fields.
-Take this CSV snippet as an example:
-
-```csv
-
- 0
- string
- string
- 10.5
-
-```
-
-Suppose that only the book `id`, and `title` elements are needed for conversion into record fields. This can be achieved by defining only the required fields in the record type and omitting the rest field:
-
-```ballerina
-type Book record {|
- int id;
- string title;
-|};
+public function main() returns error? {
+ record {}[] csvContent = [{
+ "name": "Clean Code",
+ "author": "Robert C. Martin",
+ "year": 2008,
+ "publisher": "Prentice Hall"
+ }, {
+ "name": "The Pragmatic Programmer",
+ "author": "Andrew Hunt and David Thomas",
+ "year": 1999,
+ "publisher": "Addison-Wesley"
+ }];
+
+ // The CSV data above contains publisher and year fields which are not
+ // required to be converted into a record field.
+ Book[] book = check csv:transform(csvContent);
+ io:println(book);
+}
```
-However, if the rest field is utilized (or if the record type is defined as an open record), all elements in the CSV data will be transformed into record fields:
+However, if the rest field is utilized (or if the record type is defined as an open record), all members in the CSV data will be transformed into record fields:
```ballerina
-type Book record {|
- int id;
- string title;
-|};
+type Book record {
+ string name;
+ string author;
+}
```
-In this instance, all other elements in the CSV data, such as `author` and `price` along with their attributes, will be transformed into `string` type fields with the corresponding element name as the key.
+In this instance, all other CSV header values, such as `year` and `publisher` will be transformed into `anydata-typed` fields with the corresponding CSV header as the key-value pair.
-This behavior extends to arrays as well.
+This behavior extends to arrays as well.
-The process of projecting CSV data into a record supports various use cases, including the filtering out of unnecessary elements. This functionality is anticipated to be enhanced in the future to accommodate more complex scenarios, such as filtering values based on regular expressions, among others.
+The process of projecting CSV data into a record supports various use cases, including the filtering out of unnecessary members. This functionality is anticipated to be enhanced in the future to accommodate more complex scenarios, such as filtering values based on regular expressions, among others.
## Issues and projects
-Issues and Projects tabs are disabled for this repository as this is part of the Ballerina standard library. To report bugs, request new features, start new discussions, view project boards, etc. please visit Ballerina standard library [parent repository](https://github.com/ballerina-platform/ballerina-standard-library).
+Issues and Projects tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc. please visit Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library).
This repository only contains the source code for the package.
@@ -410,8 +163,8 @@ This repository only contains the source code for the package.
### Set up the prerequisites
1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations).
- * [Oracle](https://www.oracle.com/java/technologies/downloads/)
- * [OpenJDK](https://adoptium.net/)
+ * [Oracle](https://www.oracle.com/java/technologies/downloads/)
+ * [OpenJDK](https://adoptium.net/)
2. Export your GitHub personal access token with the read package permissions as follows.
@@ -450,6 +203,5 @@ All contributors are encouraged to read the [Ballerina code of conduct](https://
## Useful links
-[//]: # (* For more information go to the [`csvdata` library](https://lib.ballerina.io/ballerina/data.csv/latest).)
* Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
-* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
\ No newline at end of file
+* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
diff --git a/ballerina-tests/build.gradle b/ballerina-tests/build.gradle
new file mode 100644
index 0000000..c83dd9d
--- /dev/null
+++ b/ballerina-tests/build.gradle
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+plugins {
+ id 'jacoco'
+ id 'groovy'
+}
+
+import org.apache.tools.ant.taskdefs.condition.Os
+
+description = 'Ballerina - CSV data module Ballerina Tests'
+
+def packageName = "data.csv"
+def packageOrg = "ballerina"
+def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
+def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/BallerinaTest.toml")
+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.csvdata.*:ballerina.*"
+def testPackages = ["union-type-tests", "user-config-tests", "parse-string-record-types-tests",
+ "parse-string-array-types-tests", "parse-list-types-tests", "parse-record-types-tests",
+ "type-compatible-tests", "unicode-tests", "constraint-validation-tests"]
+def testCommonPackage = "csv-commons"
+
+def stripBallerinaExtensionVersion(String extVersion) {
+ if (extVersion.matches(project.ext.timestampedVersionRegex)) {
+ def splitVersion = extVersion.split('-');
+ if (splitVersion.length > 3) {
+ def strippedValues = splitVersion[0..-4]
+ return strippedValues.join('-')
+ } else {
+ return extVersion
+ }
+ } else {
+ return extVersion.replace("${project.ext.snapshotVersion}", "")
+ }
+}
+
+clean {
+ delete "${project.projectDir}/${testCommonPackage}/target"
+
+ testPackages.each { testPackage ->
+ delete "${project.projectDir}/${testPackage}/target"
+ }
+}
+
+task updateTomlVersions {
+ doLast {
+ testPackages.each { testPackage ->
+ def ballerinaTomlFile = new File("${project.projectDir}/${testPackage}/Ballerina.toml")
+ def newBallerinaToml = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version)
+ newBallerinaToml = newBallerinaToml.replace("@toml.version@", tomlVersion)
+ newBallerinaToml = newBallerinaToml.replace("@test.common@", testCommonPackage.replaceAll("-", "_"))
+ newBallerinaToml = newBallerinaToml.replace("@package.name@", testPackage.replaceAll("-", "_"))
+ ballerinaTomlFile.text = newBallerinaToml
+ }
+
+ def ballerinaTomlFile = new File("${project.projectDir}/${testCommonPackage}/Ballerina.toml")
+ def newBallerinaToml = testCommonTomlFilePlaceHolder.text.replace("@project.version@", project.version)
+ newBallerinaToml = newBallerinaToml.replace("@toml.version@", tomlVersion)
+ newBallerinaToml = newBallerinaToml.replace("@package.name@", testCommonPackage.replaceAll("-", "_"))
+ ballerinaTomlFile.text = newBallerinaToml
+ }
+}
+
+def groupParams = ""
+def disableGroups = ""
+def windowsDisableGroups = "--disable-groups disabledOnWindows"
+def debugParams = ""
+def balJavaDebugParam = ""
+def testParams = ""
+def graalvmFlag = ""
+def parallelTestFlag = ""
+def skipTests = false
+
+task deleteDependencyTomlFile {
+ if (project.hasProperty("deleteDependencies")) {
+ delete "${project.projectDir}/${testCommonPackage}/Dependencies.toml"
+
+ testPackages.each { testPackage ->
+ delete "${project.projectDir}/${testPackage}/Dependencies.toml"
+ }
+ }
+}
+
+task initializeVariables {
+ if (project.hasProperty("groups")) {
+ groupParams = "--groups ${project.findProperty("groups")}"
+ }
+ if (project.hasProperty("disable")) {
+ disableGroups = "--disable-groups ${project.findProperty("disable")}"
+ }
+ if (project.hasProperty("debug")) {
+ debugParams = "--debug ${project.findProperty("debug")}"
+ }
+ if (project.hasProperty("balJavaDebug")) {
+ balJavaDebugParam = "BAL_JAVA_DEBUG=${project.findProperty("balJavaDebug")}"
+ }
+ if (project.hasProperty('balGraalVMTest')) {
+ graalvmFlag = '--graalvm'
+ }
+ if (project.hasProperty('balParallelTest')) {
+ parallelTestFlag = '--parallel'
+ }
+ if (project.hasProperty('balTests')) {
+ testPackages = project.findProperty('balTests').toString().split(",")
+ }
+ if (project.hasProperty('skipBalTests')) {
+ project.findProperty('skipBalTests').toString().split(",").each {testPackage ->
+ testPackages.remove(testPackage)
+ }
+ }
+
+
+ gradle.taskGraph.whenReady { graph ->
+ if (graph.hasTask(":${packageName}-ballerina-tests:test")) {
+ if (!project.hasProperty('balGraalVMTest')) {
+ testParams = "${testCoverageParam}"
+ }
+ } else {
+ skipTests = true
+ }
+ }
+}
+
+task publishTestCommonPackageToLocal {
+ dependsOn(":${packageName}-${packageOrg}:build")
+ dependsOn(updateTomlVersions)
+ doLast {
+ if (!skipTests) {
+ exec {
+ workingDir "${project.projectDir}/${testCommonPackage}"
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ commandLine 'cmd', '/c', "${distributionBinPath}/bal.bat pack && exit %%ERRORLEVEL%%"
+ } else {
+ commandLine 'sh', '-c', "${distributionBinPath}/bal pack"
+ }
+ }
+ exec {
+ workingDir "${project.projectDir}/${testCommonPackage}"
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ commandLine 'cmd', '/c', "${distributionBinPath}/bal.bat push --repository=local" +
+ " && exit %%ERRORLEVEL%%"
+ } else {
+ commandLine 'sh', '-c', "${distributionBinPath}/bal push --repository=local"
+ }
+ }
+ }
+ }
+}
+
+task commitTomlFiles {
+ doLast {
+ project.exec {
+ ignoreExitValue true
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the native jar versions\" Ballerina.toml Dependencies.toml"
+ } else {
+ commandLine 'sh', '-c', "git commit -m '[Automated] Update the native jar versions' Ballerina.toml Dependencies.toml"
+ }
+ }
+ }
+}
+
+task ballerinaTest {
+ dependsOn(":${packageName}-${packageOrg}:build")
+ dependsOn(updateTomlVersions)
+ dependsOn(initializeVariables)
+ dependsOn(publishTestCommonPackageToLocal)
+ finalizedBy(commitTomlFiles)
+
+ doLast {
+ testPackages.each { testPackage ->
+ if (!skipTests) {
+ exec {
+ workingDir "${project.projectDir}/${testPackage}"
+ environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test ${graalvmFlag}" +
+ " ${parallelTestFlag} ${testParams} ${groupParams} ${disableGroups} ${windowsDisableGroups}" +
+ " ${debugParams} && exit %%ERRORLEVEL%%"
+ } else {
+ commandLine 'sh', '-c', "${distributionBinPath}/bal test ${graalvmFlag} ${parallelTestFlag} ${testParams}" +
+ " ${groupParams} ${disableGroups} ${debugParams}"
+ }
+ }
+ if (project.hasProperty('balGraalVMTest')) {
+ exec {
+ workingDir "${project.projectDir}/${testPackage}"
+ environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ commandLine 'cmd', '/c', "${distributionBinPath}/bal.bat clean"
+ } else {
+ commandLine 'sh', '-c', "${distributionBinPath}/bal clean"
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+publishing {
+ repositories {
+ maven {
+ name = "GitHubPackages"
+ url = uri("https://maven.pkg.github.com/ballerina-platform/module-${packageOrg}-${packageName}")
+ credentials {
+ username = System.getenv("packageUser")
+ password = System.getenv("packagePAT")
+ }
+ }
+ }
+}
+
+test {
+ dependsOn(ballerinaTest)
+}
+
+build.dependsOn ":${packageName}-ballerina:build"
+build.dependsOn ":${packageName}-compiler-plugin:build"
+
+test.dependsOn ":${packageName}-ballerina:build"
+test.dependsOn ":${packageName}-compiler-plugin:build"
+test.dependsOn ":${packageName}-compiler-plugin-tests:test"
+
+publishToMavenLocal.dependsOn build
+publish.dependsOn build
diff --git a/ballerina-tests/constraint-validation-tests/Ballerina.toml b/ballerina-tests/constraint-validation-tests/Ballerina.toml
new file mode 100644
index 0000000..84093d9
--- /dev/null
+++ b/ballerina-tests/constraint-validation-tests/Ballerina.toml
@@ -0,0 +1,16 @@
+[package]
+org = "ballerina"
+name = "constraint_validation_tests"
+version = "0.1.0"
+
+[[dependency]]
+org = "ballerina"
+name = "csv_commons"
+repository = "local"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
+
+[build-options]
+graalvmBuildOptions = "-H:+IncludeAllLocales"
diff --git a/ballerina-tests/constraint-validation-tests/Dependencies.toml b/ballerina-tests/constraint-validation-tests/Dependencies.toml
new file mode 100644
index 0000000..7f54d3a
--- /dev/null
+++ b/ballerina-tests/constraint-validation-tests/Dependencies.toml
@@ -0,0 +1,101 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.9.0"
+
+[[package]]
+org = "ballerina"
+name = "constraint"
+version = "1.5.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "constraint", moduleName = "constraint"}
+]
+
+[[package]]
+org = "ballerina"
+name = "constraint_validation_tests"
+version = "0.1.0"
+dependencies = [
+ {org = "ballerina", name = "constraint"},
+ {org = "ballerina", name = "data.csv"},
+ {org = "ballerina", name = "test"}
+]
+modules = [
+ {org = "ballerina", packageName = "constraint_validation_tests", moduleName = "constraint_validation_tests"}
+]
+
+[[package]]
+org = "ballerina"
+name = "data.csv"
+version = "0.1.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "data.csv", moduleName = "data.csv"}
+]
+
+[[package]]
+org = "ballerina"
+name = "jballerina.java"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "lang.__internal"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.object"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.array"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.__internal"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.error"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.object"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "test"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.array"},
+ {org = "ballerina", name = "lang.error"}
+]
+modules = [
+ {org = "ballerina", packageName = "test", moduleName = "test"}
+]
+
diff --git a/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal b/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal
new file mode 100644
index 0000000..577f783
--- /dev/null
+++ b/ballerina-tests/constraint-validation-tests/tests/constraint_validation_test.bal
@@ -0,0 +1,130 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/constraint;
+import ballerina/data.csv;
+import ballerina/test;
+
+type ConstrainedRec record {
+ @constraint:Int {
+ minValue: 3,
+ maxValue: 10
+ }
+ int a?;
+ @constraint:String {
+ minLength: 2
+ }
+ string b;
+};
+
+@constraint:Array {length: 4}
+type ConstrainedList int[][];
+
+@test:Config
+function testConstraintWithLists() returns error? {
+ ConstrainedList|csv:Error cList1 = csv:parseString(string `1
+ 2
+ 3
+ 4`, {header: (), customHeadersIfHeadersAbsent: ["a", "b", "c", "d"]});
+ test:assertEquals(cList1, [[1], [2], [3], [4]]);
+
+ cList1 = csv:parseString(string `1
+ 2
+ 3
+ 4
+ 5
+ 6`, {header: null, customHeadersIfHeadersAbsent: ["a", "b", "c", "d", "e", "f"]});
+ test:assertTrue(cList1 is csv:Error);
+ test:assertTrue((cList1).message().startsWith("Validation failed")
+ && (cList1).message().includes("length"));
+
+ cList1 = csv:parseString(string `1
+ 2
+ 3
+ 4
+ 5
+ 6`, {header: (), customHeadersIfHeadersAbsent: ["a", "b", "c", "d", "e", "f"], enableConstraintValidation: false});
+ test:assertEquals(cList1, [[1], [2], [3], [4], [5], [6]]);
+
+ cList1 = csv:transform([{"a": 1}, {"a": 1}, {"a": 1}, {"a": 1}], {});
+ test:assertEquals(cList1, [[1], [1], [1], [1]]);
+
+ cList1 = csv:transform([{"a": 1}, {"a": 1}, {"a": 1}, {"a": 1}, {"a": 1}, {"a": 1}], {});
+ test:assertTrue(cList1 is csv:Error);
+ test:assertTrue((cList1).message().startsWith("Validation failed")
+ && (cList1).message().includes("length"));
+
+ cList1 = csv:parseList([["1"], ["2"], ["3"], ["4"]], {customHeaders: ["a", "b", "c", "d"]});
+ test:assertEquals(cList1, [[1], [2], [3], [4]]);
+
+ 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"));
+}
+
+@test:Config
+function testConstraintWithRecords() returns error? {
+ ConstrainedRec[]|csv:Error cRec1 = csv:parseString(string `a,b
+ 4,abc
+ 3, cde`);
+ test:assertEquals(cRec1, [{a: 4, b: "abc"}, {a: 3, b: "cde"}]);
+
+ ConstrainedRec[]|csv:Error cRec1_2 = csv:parseString(string `a,b
+ 4,abc
+ 3, cde`, {enableConstraintValidation: false});
+ test:assertEquals(cRec1_2, [{a: 4, b: "abc"}, {a: 3, b: "cde"}]);
+
+ cRec1 = csv:parseString(string `a,b
+ 4,abc
+ 11, cde`);
+ test:assertTrue(cRec1 is csv:Error);
+ test:assertTrue((cRec1).message().startsWith("Validation failed")
+ && (cRec1).message().includes("maxValue"));
+
+ cRec1 = csv:parseString(string `a,b
+ 4,abc
+ 5, "b"`, {});
+ test:assertTrue(cRec1 is csv:Error);
+ test:assertTrue((cRec1).message().startsWith("Validation failed")
+ && (cRec1).message().includes("minLength"));
+
+ cRec1 = csv:transform([{"a": 4, "b": "abc"}, {"a": 3, "b": "cde"}], {});
+ test:assertEquals(cRec1, [{a: 4, b: "abc"}, {a: 3, b: "cde"}]);
+
+ cRec1 = csv:transform([{"a": 4, "b": "abc"}, {"a": 11, "b": "cde"}], {});
+ test:assertTrue(cRec1 is csv:Error);
+ test:assertTrue((cRec1).message().startsWith("Validation failed")
+ && (cRec1).message().includes("maxValue"));
+
+ cRec1 = csv:transform([{"a": 4, "b": "abc"}, {"a": 5, "b": "b"}], {});
+ test:assertTrue(cRec1 is csv:Error);
+ test:assertTrue((cRec1).message().startsWith("Validation failed")
+ && (cRec1).message().includes("minLength"));
+
+ cRec1 = csv:parseList([["4", "abc"], ["3", "cde"]], {customHeaders: ["a", "b"]});
+ test:assertEquals(cRec1, [{a: 4, b: "abc"}, {a: 3, b: "cde"}]);
+
+ 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: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/csv-commons/Ballerina.toml b/ballerina-tests/csv-commons/Ballerina.toml
new file mode 100644
index 0000000..13c0bc8
--- /dev/null
+++ b/ballerina-tests/csv-commons/Ballerina.toml
@@ -0,0 +1,7 @@
+[package]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
diff --git a/ballerina-tests/csv-commons/Dependencies.toml b/ballerina-tests/csv-commons/Dependencies.toml
new file mode 100644
index 0000000..cf3bbba
--- /dev/null
+++ b/ballerina-tests/csv-commons/Dependencies.toml
@@ -0,0 +1,17 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.10.0-20240801-104200-87df251c"
+
+[[package]]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+modules = [
+ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"}
+]
+
diff --git a/ballerina-tests/csv-commons/Package.md b/ballerina-tests/csv-commons/Package.md
new file mode 100644
index 0000000..8a7ecb6
--- /dev/null
+++ b/ballerina-tests/csv-commons/Package.md
@@ -0,0 +1,3 @@
+## Package overview
+
+This package provides APIs for testing ballerina CSV data module.
diff --git a/ballerina-tests/csv-commons/test_utils.bal b/ballerina-tests/csv-commons/test_utils.bal
new file mode 100644
index 0000000..2609cd9
--- /dev/null
+++ b/ballerina-tests/csv-commons/test_utils.bal
@@ -0,0 +1,39 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+public function generateErrorMessageForMissingRequiredField(string 'field) returns string {
+ return string `no matching header value is found for the required field '${'field}'`;
+}
+
+public function generateErrorMessageForInvalidCast(string value, string 'type) returns string {
+ return string `value '${value}' cannot be cast into '${'type}'`;
+}
+
+public function generateErrorMessageForInvalidFieldType(string value, string 'key) returns string {
+ return string `no mapping type found for value '${value}' in key '${'key}'`;
+}
+
+public function generateErrorMessageForInvalidValueForArrayType(string value, string index, string arrayType) returns string {
+ return string `value '${value}' in index '${index}' is not compatible with array type '${arrayType}'`;
+}
+
+public function generateErrorMessageForInvalidHeaders(string value, string 'type) returns string{
+ return string `value '${value}' cannot be cast into '${'type}', because fields in '${'type}' or the provided expected headers are not matching with the '${value}'`;
+}
+
+public function generateErrorMessageForInvalidCustomHeader(string header) returns string {
+ return string `Header '${header}' cannot be found in data rows`;
+}
diff --git a/ballerina-tests/parse-list-types-tests/Ballerina.toml b/ballerina-tests/parse-list-types-tests/Ballerina.toml
new file mode 100644
index 0000000..258e9ff
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/Ballerina.toml
@@ -0,0 +1,16 @@
+[package]
+org = "ballerina"
+name = "parse_list_types_tests"
+version = "0.1.0"
+
+[[dependency]]
+org = "ballerina"
+name = "csv_commons"
+repository = "local"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
+
+[build-options]
+graalvmBuildOptions = "-H:+IncludeAllLocales"
diff --git a/ballerina-tests/parse-list-types-tests/Dependencies.toml b/ballerina-tests/parse-list-types-tests/Dependencies.toml
new file mode 100644
index 0000000..3e4b472
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/Dependencies.toml
@@ -0,0 +1,98 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.10.0-20240801-104200-87df251c"
+
+[[package]]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+scope = "testOnly"
+modules = [
+ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"}
+]
+
+[[package]]
+org = "ballerina"
+name = "data.csv"
+version = "0.1.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "data.csv", moduleName = "data.csv"}
+]
+
+[[package]]
+org = "ballerina"
+name = "jballerina.java"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "lang.__internal"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.object"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.array"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.__internal"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.error"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.object"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "parse_list_types_tests"
+version = "0.1.0"
+dependencies = [
+ {org = "ballerina", name = "csv_commons"},
+ {org = "ballerina", name = "data.csv"},
+ {org = "ballerina", name = "test"}
+]
+modules = [
+ {org = "ballerina", packageName = "parse_list_types_tests", moduleName = "parse_list_types_tests"}
+]
+
+[[package]]
+org = "ballerina"
+name = "test"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.array"},
+ {org = "ballerina", name = "lang.error"}
+]
+modules = [
+ {org = "ballerina", packageName = "test", moduleName = "test"}
+]
+
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
new file mode 100644
index 0000000..a094cdf
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_list_test.bal
@@ -0,0 +1,598 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvWithTypeForTupleAndTupleAsExpectedType() {
+ StringTuple1Array|csv:Error st1st1 = csv:parseList([st1, st1], {}, StringTuple1Array);
+ test:assertEquals(st1st1, [
+ [s1, s2, "", ""],
+ [s1, s2, "", ""]
+ ]);
+
+ 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:parseList([st3, st3], {}, StringTuple1Array);
+ test:assertEquals(st3st1, [
+ [s1, s2, "", ""],
+ [s1, s2, "", ""]
+ ]);
+
+ 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:parseList([st1, st1], {}, StringTuple2Array);
+ test:assertEquals(st1st2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringTuple2Array|csv:Error st2st2 = csv:parseList([st2, st2], {}, StringTuple2Array);
+ test:assertEquals(st2st2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringTuple2Array|csv:Error st3st2 = csv:parseList([st3, st3], {}, StringTuple2Array);
+ test:assertEquals(st3st2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringTuple2Array|csv:Error st4st2 = csv:parseList([st4, st4], {}, StringTuple2Array);
+ test:assertEquals(st4st2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringTuple3Array|csv:Error st1st3 = csv:parseList([st1, st1], {}, StringTuple3Array);
+ test:assertEquals(st1st3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, StringTuple3Array);
+ test:assertEquals(st3st3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringTuple3Array|csv:Error st4st3 = csv:parseList([st4, st4], {}, StringTuple3Array);
+ test:assertEquals(st4st3, [
+ [s1, s2, s3, s2],
+ [s1, s2, s3, s2]
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndTupleAsExpectedType2() {
+ StringTuple4Array|csv:Error st1st4 = csv:parseList([st1, st1], {}, StringTuple4Array);
+ test:assertEquals(st1st4, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, StringTuple4Array);
+ test:assertEquals(st3st4, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, AnydataTuple3Array);
+ test:assertEquals(st1anydt3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, AnydataTuple3Array);
+ test:assertEquals(st3anydt3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, JsonTuple3Array);
+ test:assertEquals(st1jt3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, JsonTuple3Array);
+ test:assertEquals(st3jt3, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, DecimalTuple4Array);
+ test:assertTrue(st1dta is csv:Error);
+ test:assertEquals((st1dta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal"));
+
+ 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:parseList([st3, st3], {}, NilTuple3Array);
+ test:assertTrue(st3nta is csv:Error);
+ test:assertEquals((st3nta).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "()"));
+
+ 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: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: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: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: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: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: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: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: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: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:parseList(
+ [["1", "a"], ["1", "a"]]);
+ test:assertEquals(ct1bt13, [
+ ["1", "a"],
+ ["1", "a"]
+ ]);
+
+ [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:parseList(
+ [["1", "()"], ["1", "2"]]);
+ test:assertEquals(ct1bt15, [
+ [1, ()],
+ [1, 2]
+ ]);
+
+ 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:parseList(
+ [["a", "b"], ["a", "b"]]);
+ test:assertTrue(ct1bt17 is csv:Error);
+ test:assertEquals((ct1bt17).message(), common:generateErrorMessageForInvalidValueForArrayType("a", "0", "int"));
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndArrayAsExpectedType() {
+ StringArrayArray|csv:Error st1saa = csv:parseList([st1, st1], {}, StringArrayArray);
+ test:assertEquals(st1saa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, StringArrayArray);
+ test:assertEquals(st3saa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, NillableStringArrayArray);
+ test:assertEquals(st1nsaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, NillableStringArrayArray);
+ test:assertEquals(st3nsaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, NillableIntOrUnionStringArrayArray);
+ test:assertEquals(st1nsuiaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndTupleAsExpectedType4() {
+ 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:parseList([st3, st3], {}, NillableIntOrUnionStringArrayArray);
+ test:assertEquals(st3nsuiaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, StringArray2Array);
+ test:assertEquals(st1saa2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringArray2Array|csv:Error st2saa2 = csv:parseList([st2, st2], {}, StringArray2Array);
+ test:assertEquals(st2saa2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringArray2Array|csv:Error st3saa2 = csv:parseList([st3, st3], {}, StringArray2Array);
+ test:assertEquals(st3saa2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ StringArray2Array|csv:Error st4saa2 = csv:parseList([st4, st4], {}, StringArray2Array);
+ test:assertEquals(st4saa2, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ JsonArray1Array|csv:Error st1jaa = csv:parseList([st1, st1], {}, JsonArray1Array);
+ test:assertEquals(st1jaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, JsonArray1Array);
+ test:assertEquals(st3jaa, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, AnydataArray1Array);
+ test:assertEquals(st1anyda, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st3, st3], {}, AnydataArray1Array);
+ test:assertEquals(st3anyda, [
+ [s1, s2],
+ [s1, s2]
+ ]);
+
+ 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:parseList([st1, st1], {}, DecimalArray1Array);
+ test:assertTrue(st1dda is csv:Error);
+ test:assertEquals((st1dda).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal"));
+
+ DecimalArray1Array|csv:Error st3dda = csv:parseList([st3, st3], {}, DecimalArray1Array);
+ test:assertTrue(st3dda is csv:Error);
+ test:assertEquals((st3dda).message(), common:generateErrorMessageForInvalidValueForArrayType("string", "0", "decimal"));
+}
+
+@test:Config
+function testArrayIndexes() {
+ string[][] csv = [["1", "2", "3"], ["3", "4", "5"], ["5", "6", "7"], ["7", "8", "9"]];
+
+ [int, int][2]|csv:Error rec3_2 = csv:parseList(csv);
+ test:assertEquals(rec3_2, [
+ [1, 2],
+ [3, 4]
+ ]);
+
+ int[2][]|csv:Error rec5 = csv:parseList(csv);
+ test:assertEquals(rec5, [
+ [1, 2, 3],
+ [3, 4, 5]
+ ]);
+}
+
+@test:Config
+function testParseListsWithOutputHeaders() {
+ [string, boolean, int][]|csv:Error ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1});
+ test:assertEquals(ct1bt1, [
+ ["a", true, 1]
+ ]);
+
+ [string, boolean, int][]|[anydata...][]|csv:Error ct1bt1_union = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headerRows: 2});
+ test:assertTrue(ct1bt1_union is csv:Error);
+ test:assertEquals((ct1bt1_union).message(), "custom headers should be provided");
+
+ ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1, customHeaders: ["h1", "h2", "h3"]});
+ test:assertEquals(ct1bt1, [
+ ["a", true, 1]
+ ]);
+
+ 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:parseList([["a", "true", "1"]], {headerRows: 1});
+ test:assertEquals(ct1bt1, []);
+
+ (boolean|int|string)[][]|csv:Error ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headerRows: 1});
+ test:assertEquals(ct1bt1_2, [
+ ["a", true, 1]
+ ]);
+
+ 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:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 0, customHeaders: ["h1", "h2", "h3"]});
+ test:assertEquals(ct1bt1_2, [
+ ["a", true, 1],
+ ["a", true, 1]
+ ]);
+
+ [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: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: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"));
+
+ [string, boolean, int|string][]|[anydata...][]|csv:Error ct1bt1_3_with_union = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headerRows: 21, outputWithHeaders: true});
+ test:assertTrue(ct1bt1_3_with_union is csv:Error);
+ test:assertEquals((ct1bt1_3_with_union).message(), "custom headers should be provided");
+
+ 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: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: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: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: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: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: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: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:parseList([["1", "a"], ["1", "a"]]);
+ test:assertEquals(ct1bt2, [
+ ["1", "a"],
+ ["1", "a"]
+ ]);
+
+ [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: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: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: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: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: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
new file mode 100644
index 0000000..79162d7
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/tests/parse_list_type_as_record_test.bal
@@ -0,0 +1,931 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType() {
+ 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:parseList([st2, st2], {});
+ test:assertTrue(st2sr1 is csv:Error);
+ test:assertEquals((st2sr1).message(), common:generateErrorMessageForMissingRequiredField("s3"));
+
+ 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: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: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: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:parseList([st1, st1], {});
+ test:assertEquals(st1sr10, [
+ {'1: "string", '2: ""},
+ {'1: "string", '2: ""}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1sr19, [
+ {s1: "", s2: "", "1": s1, "2": s2},
+ {s1: "", s2: "", "1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1sr20, [
+ {s1: "", s2: ""},
+ {s1: "", s2: ""}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType2() {
+ StringRecord20Array|csv:Error st2sr20 = csv:parseList([st2, st2], {});
+ test:assertEquals(st2sr20, [
+ {s1: "", s2: ""},
+ {s1: "", s2: ""}
+ ]);
+
+ StringRecord21Array|csv:Error st1sr21 = csv:parseList([st1, st1], {});
+ test:assertEquals(st1sr21, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1sr22, [
+ {s1: "", s2: "", "1": s1, "2": s2},
+ {s1: "", s2: "", "1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1sr23, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr15, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ CustomRecord15Array|csv:Error st2cr15 = csv:parseList([st2, st2], {});
+ test:assertEquals(st2cr15, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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: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:parseList([st1, st1], {});
+ test:assertEquals(st1cr17, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType3() {
+ 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:parseList([st1, st1], {});
+ test:assertTrue(st1cr18 is csv:Error);
+ test:assertEquals((st1cr18).message(), common:generateErrorMessageForMissingRequiredField("3"));
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr19, [
+ {'1: s1, '2: s2, '3: "", '4: ""},
+ {'1: s1, '2: s2, '3: "", '4: ""}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr20, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr21, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr22, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType4() {
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr23, [
+ {"1": s1, "2": s2, a: ""},
+ {"1": s1, "2": s2, a: ""}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr24, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertTrue(st1cr25 is csv:Error);
+ test:assertEquals((st1cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1"));
+
+ 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:parseList([st3, st3], {});
+ test:assertTrue(st3cr25 is csv:Error);
+ test:assertEquals((st3cr25).message(), common:generateErrorMessageForInvalidFieldType("string", "1"));
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cr26 , [
+ {'1: s1},
+ {'1: s1}
+ ]);
+
+ CustomRecord26Array|csv:Error st2cr26 = csv:parseList([st2, st2], {});
+ test:assertEquals(st2cr26 , [
+ {'1: s1},
+ {'1: s1}
+ ]);
+
+ CustomRecord26Array|csv:Error st3cr26 = csv:parseList([st3, st3], {});
+ test:assertEquals(st3cr26 , [
+ {'1: s1},
+ {'1: s1}
+ ]);
+
+ CustomRecord26Array|csv:Error st4cr26 = csv:parseList([st4, st4], {});
+ test:assertEquals(st4cr26 , [
+ {'1: s1},
+ {'1: s1}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType5() {
+ 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:parseList([st4, st4], {});
+ test:assertTrue(st4sr1 is csv:Error);
+ test:assertEquals((st4sr1).message(), common:generateErrorMessageForMissingRequiredField("s3"));
+
+ 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: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:parseList([st3, st3], {});
+ test:assertTrue(st3sr9 is csv:Error);
+ test:assertEquals((st3sr9).message(), common:generateErrorMessageForMissingRequiredField("s1"));
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sr10, [
+ {'1: "string", '2: ""},
+ {'1: "string", '2: ""}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sr19, [
+ {s1: "", s2: "", "1": s1, "2": s2},
+ {s1: "", s2: "", "1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sr20, [
+ {s1: "", s2: ""},
+ {s1: "", s2: ""}
+ ]);
+
+ StringRecord20Array|csv:Error st4sr20 = csv:parseList([st4, st4], {});
+ test:assertEquals(st4sr20, [
+ {s1: "", s2: ""},
+ {s1: "", s2: ""}
+ ]);
+
+ StringRecord21Array|csv:Error st3sr21 = csv:parseList([st3, st3], {});
+ test:assertEquals(st3sr21, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sr22, [
+ {s1: "", s2: "", "1": s1, "2": s2},
+ {s1: "", s2: "", "1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sr23, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr15, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType6() {
+ CustomRecord15Array|csv:Error st4cr15 = csv:parseList([st4, st4], {});
+ test:assertEquals(st4cr15, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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: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:parseList([st3, st3], {});
+ test:assertEquals(st3cr17, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertTrue(st3cr18 is csv:Error);
+ test:assertEquals((st3cr18).message(), common:generateErrorMessageForMissingRequiredField("3"));
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr19, [
+ {'1: s1, '2: s2, '3: "", '4: ""},
+ {'1: s1, '2: s2, '3: "", '4: ""}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr20, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr21, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr22, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr23, [
+ {"1": s1, "2": s2, a: ""},
+ {"1": s1, "2": s2, a: ""}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cr24, [
+ {"1": s1, "2": s2},
+ {"1": s1, "2": s2}
+ ]);
+
+ 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}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() {
+ 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:parseList(
+ [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]],
+ {customHeaders: ["f", "e", "d", "c", "b", "a"]});
+ test:assertEquals(ct1br6, [
+ {a: (), b: 2.23, c: 0, d: true, e: 1, f: "a"},
+ {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:parseList(
+ [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]],
+ {customHeaders: ["f", "e", "d", "c", "b", "a"]});
+ test:assertEquals(ct1br7, [
+ {c: 0, d: true, e: 1, f: "a"},
+ {c: 2.23, d: true, e: 1, f: "a"}
+ ]);
+
+ 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, [
+ {a: (), b: 2.23, c: 0, d: true, e: 1, f: "a"},
+ {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:parseList(
+ [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]],
+ {customHeaders: ["f", "e", "d", "c", "b", "a"]});
+ test:assertEquals(ct1br9, [
+ {a: (), b: 2.23, c: 0, d: true, e: 1, f: "a"},
+ {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: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, [
+ {a: (), b: 2.23, c: 0, d: "true", e: 1, f: "a"},
+ {a: (), b: 0, c: 2.23, d: "true", e: 1, f: "a"}
+ ]);
+
+ record {|int|() a; float b; decimal? c; boolean|string d; int|string e; string f; string...;|}[]|csv:Error ct1br9_3 = 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_3, [
+ {a: (), b: 2.23, c: 0, d: true, e: 1, f: "a"},
+ {a: (), b: 0, c: 2.23, d: true, e: 1, f: "a"}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() {
+ 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"]});
+ 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: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:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"]});
+ 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:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"]});
+ test:assertEquals(ct1br4_4, [
+ {a: "a", b: true, c: 1}
+ ]);
+
+ record {string a; boolean b; int c;}[]|record {}[]|csv:Error ct1br4_5 = csv:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2});
+ 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:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"]});
+ test:assertEquals(ct1br4_4_2, [
+ {a: "a", b: true, c: 1}
+ ]);
+
+ record {|string a; boolean b; int...;|}[]|record {}[]|csv:Error ct1br4_5_2 = csv:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2});
+ test:assertTrue(ct1br4_5_2 is csv:Error);
+ test:assertEquals((ct1br4_5).message(), "custom headers should be provided");
+
+ map[]|csv:Error ct2br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1, customHeaders: ["a", "c", "b"]});
+ test:assertEquals(ct2br4_3, [
+ {a: "a", b: true, c: 1},
+ {a: "a", b: true, c: 1}
+ ]);
+
+ map[]|csv:Error ct2br4_3_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 3, customHeaders: ["a", "c", "b"]});
+ test:assertEquals(ct2br4_3_2, []);
+
+ map[]|csv:Error ct2br4_4 = csv:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 2, customHeaders: ["a", "c", "b"]});
+ test:assertEquals(ct2br4_4, [
+ {a: "a", b: true, c: 1}
+ ]);
+
+ 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"]});
+ test:assertEquals(ct2br4_5, [
+ {a: "a", b: "true", c: "1"},
+ {a: "a", b: "true", c: "1"}
+ ]);
+
+ map[]|record {}[]|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[]|record {}[]|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:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1});
+ test:assertEquals(ct2br4_8, [
+ {"a": "a", "1": "1", "true": "true"},
+ {"a": "a", "1": "1", "true": "true"},
+ {"a": "a", "1": "1", "true": "true"}
+ ]);
+
+ map[]|csv:Error ct2br4_8_2 = csv:parseList(
+ [["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headerRows: 1});
+ test:assertEquals(ct2br4_8_2, [
+ {"a": "a", "1": "1", "true": "true"},
+ {"a": "a", "1": "1", "true": "true"},
+ {"a": "a", "1": "1", "true": "true"}
+ ]);
+
+ map[]|csv:Error ct2br4_9 = csv:parseList(
+ [["a", "c", "b"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1});
+ test:assertEquals(ct2br4_9, [
+ {a: "a", b: "true", c: "2"},
+ {a: "a", b: "true", c: "3"},
+ {a: "a", b: "true", c: "4"},
+ {a: "a", b: "true", c: "5"}
+ ]);
+
+ map[]|csv:Error ct2br4_10 = csv:parseList(
+ [["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headerRows: 1});
+ test:assertEquals(ct2br4_10, [
+ {a: "a", c: true, b: 2},
+ {a: "a", c: true, b: 3},
+ {a: "a", c: true, b: 4},
+ {a: "a", c: true, b: 5}
+ ]);
+
+ 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});
+ test:assertEquals(ct2br4_10_2, [
+ {a: "a", c: true, b: 2},
+ {a: "a", c: true, b: 3},
+ {a: "a", c: true, b: 4},
+ {a: "a", c: true, b: 5}
+ ]);
+
+ map[]|record {}[]|csv:Error ct2br4_10_3 = 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_3, [
+ {c: "a", e: true, d: 2},
+ {c: "a", e: true, d: 3},
+ {c: "a", e: true, d: 4},
+ {c: "a", e: true, d: 5}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndRecordAsExpectedType8() {
+ 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, [
+ {a: "null", b: "2.23", c: 0, d: true, e: 1, f: "a"},
+ {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:parseList(
+ [["a", "1", "true", "0", "2.23", "null"], ["a", "1", "true", "2.23", "0", "()"]],
+ {customHeaders: ["f", "e", "d", "c", "b", "a"]});
+ test:assertEquals(ct1br11, [
+ {a: (), c: 0, d: true, e: 1, f: "a"},
+ {a: (), c: 2.23, d: true, e: 1, f: "a"}
+ ]);
+
+ 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, [
+ {a: ()},
+ {a: ()}
+ ]);
+
+ record {|string?...;|}[]|csv:Error ct1br13 = csv:parseList(
+ [["a", "1"], ["a", "1"]],
+ {customHeaders: ["f", "e"]});
+ test:assertEquals(ct1br13, [
+ {e: "1", f: "a"},
+ {e: "1", f: "a"}
+ ]);
+
+ record {|boolean...;|}[]|csv:Error ct1br14 = csv:parseList(
+ [["2.23", "null"], ["7", "()"]],
+ {customHeaders: ["b", "a"]});
+ test:assertEquals(ct1br14, [
+ {},
+ {}
+ ]);
+
+ map[]|csv:Error ct1br15 = csv:parseList(
+ [["2", "()"], ["2", "1"], ["()", "2"]],
+ {customHeaders: ["f", "e"]});
+ test:assertEquals(ct1br15, [
+ {e: (), f: 2},
+ {e: 1, f: 2},
+ {e: 2, f: ()}
+ ]);
+
+ record {|boolean...;|}[]|csv:Error ct1br16 = csv:parseList(
+ [["2.23", "null"], ["7", "()"]],
+ {customHeaders: ["b", "a"]});
+ test:assertEquals(ct1br16, [
+ {},
+ {}
+ ]);
+}
+
+@test:Config
+function testArrayIndexesWithRecordAsExpectedType() {
+ string[][] csv = [["1", "2", "3"], ["3", "4", "5"], ["5", "6", "7"], ["7", "8", "9"]];
+
+ 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}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndMapAsExpectedType() {
+ StringMapArray|csv:Error st1sma = csv:parseList([st1, st1], {});
+ test:assertEquals(st1sma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3sma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1niusma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3niusma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1iusma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3iusma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1jma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForTupleAndMapAsExpectedType2() {
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3jma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1anydma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3anydma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1cma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st3, st3], {});
+ test:assertEquals(st3cma , [
+ {'1: s1, '2: s2},
+ {'1: s1, '2: s2}
+ ]);
+
+ 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:parseList([st1, st1], {});
+ test:assertEquals(st1nma, ([
+ {},
+ {}
+ ]));
+
+ IntegerMapArray|csv:Error st2ima = csv:parseList([st2, st2], {});
+ test:assertEquals(st2ima, ([
+ {},
+ {}
+ ]));
+
+ DecimalMapArray|csv:Error st3dma = csv:parseList([st3, st3], {});
+ test:assertEquals(st3dma, ([
+ {},
+ {}
+ ]));
+
+ BooleanMapArray|csv:Error st4bma = csv:parseList([st4, st4], {});
+ test:assertEquals(st4bma, ([
+ {},
+ {}
+ ]));
+}
diff --git a/ballerina-tests/parse-list-types-tests/tests/test_data_values.bal b/ballerina-tests/parse-list-types-tests/tests/test_data_values.bal
new file mode 100644
index 0000000..b2bc041
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/tests/test_data_values.bal
@@ -0,0 +1,24 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+final string s1 = "string";
+final string s2 = "";
+final string:Char s3 = "a";
+
+final [string, string] st1 = [s1, s2];
+final [string, string, string, string] st2 = [s1, s2, s3, s2];
+final [string...] st3 = [s1, s2];
+final [string, string, string...] st4 = [s1, s2, s3, s2];
diff --git a/ballerina-tests/parse-list-types-tests/tests/types.bal b/ballerina-tests/parse-list-types-tests/tests/types.bal
new file mode 100644
index 0000000..930205f
--- /dev/null
+++ b/ballerina-tests/parse-list-types-tests/tests/types.bal
@@ -0,0 +1,307 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+type StringRecord1 record {
+ string s1;
+ string s2;
+ string s3;
+};
+
+type StringRecord2 record {|
+ string s1;
+ string s2;
+ string s3;
+|};
+
+type StringRecord9 record {|
+ string s1;
+ string s2;
+ string...;
+|};
+
+type StringRecord10 record {|
+ string...;
+|};
+
+type StringRecord19 record {
+ string s1 = "";
+ string s2 = "";
+};
+
+type StringRecord20 record {|
+ string s1 = "";
+ string s2 = "";
+|};
+
+type StringRecord21 record {
+};
+
+type StringRecord22 record {|
+ string s1 = "";
+ string s2 = "";
+ json...;
+|};
+
+type StringRecord23 record {|
+ json...;
+|};
+
+type CustomRecord15 record {|
+ string '1;
+ string '2;
+|};
+
+type CustomRecord16 record {|
+ string '1;
+ string '2;
+ string '3;
+ string '4;
+|};
+
+type CustomRecord17 record {
+ string '1;
+ string '2;
+};
+
+type CustomRecord18 record {
+ string '1;
+ string '2;
+ string '3;
+ string '4;
+};
+
+type CustomRecord19 record {
+ string '1;
+ string '2;
+ string '3 = "";
+ string '4 = "";
+};
+
+type CustomRecord20 record {
+ string '1;
+};
+
+type CustomRecord21 record {|
+ string '1;
+ json...;
+|};
+
+type CustomRecord22 record {|
+ string '1;
+ string...;
+|};
+
+type CustomRecord23 record {|
+ string '1;
+ string a = "";
+ string...;
+|};
+
+type CustomRecord24 record {|
+ string '1;
+ string '2 = "";
+ string...;
+|};
+
+type CustomRecord25 record {|
+ int '1;
+ string...;
+|};
+
+type CustomRecord26 record {|
+ string '1;
+ int...;
+|};
+
+type BooleanTuple4 [boolean...];
+
+type NilTuple3 [(), ()...];
+
+type IntegerTuple3 [int, int...];
+
+type IntegerTuple4 [int...];
+
+type DecimalTuple4 [decimal...];
+
+type StringTuple1 [string, string, string, string];
+
+type StringTuple2 [string, string];
+
+type StringTuple3 [string, string...];
+
+type StringTuple4 [string...];
+
+type AnydataTuple3 [anydata, anydata...];
+
+type JsonTuple3 [json, json...];
+
+type IntegerArray1 int[];
+
+type IntegerArray2 int[2];
+
+type IntegerArray3 int[];
+
+type IntegerArray4 int[2];
+
+type IntegerArray5 int[3];
+
+type IntegerArray6 int[4];
+
+type StringArray string[];
+
+type NillableStringArray string?[];
+
+type NillableIntOrUnionStringArray (int|string?)[];
+
+type StringArray1 string[];
+
+type StringArray2 string[2];
+
+type DecimalArray1 decimal[];
+
+type JsonArray1 json[];
+
+type AnydataArray1 anydata[];
+
+type IntegerMap map;
+
+type StringMap map;
+
+type NillableIntUnionStringMap map;
+
+type IntUnionStringMap map;
+
+type DecimalMap map;
+
+type BooleanMap map;
+
+type NilMap map<()>;
+
+type JsonMap map;
+
+type AnydataMap map;
+
+type CustomMap map;
+
+type StringRecord1Array StringRecord1[];
+
+type StringRecord2Array StringRecord2[];
+
+type StringRecord9Array StringRecord9[];
+
+type StringRecord10Array StringRecord10[];
+
+type StringRecord19Array StringRecord19[];
+
+type StringRecord20Array StringRecord20[];
+
+type StringRecord21Array StringRecord21[];
+
+type StringRecord22Array StringRecord22[];
+
+type StringRecord23Array StringRecord23[];
+
+type CustomRecord15Array CustomRecord15[];
+
+type CustomRecord16Array CustomRecord16[];
+
+type CustomRecord17Array CustomRecord17[];
+
+type CustomRecord18Array CustomRecord18[];
+
+type CustomRecord19Array CustomRecord19[];
+
+type CustomRecord20Array CustomRecord20[];
+
+type CustomRecord21Array CustomRecord21[];
+
+type CustomRecord22Array CustomRecord22[];
+
+type CustomRecord23Array CustomRecord23[];
+
+type CustomRecord24Array CustomRecord24[];
+
+type CustomRecord25Array CustomRecord25[];
+
+type CustomRecord26Array CustomRecord26[];
+
+type BooleanTuple4Array BooleanTuple4[];
+
+type NilTuple3Array NilTuple3[];
+type IntegerTuple3Array IntegerTuple3[];
+
+type IntegerTuple4Array IntegerTuple4[];
+
+type DecimalTuple4Array DecimalTuple4[];
+
+type StringTuple1Array StringTuple1[];
+
+type StringTuple2Array StringTuple2[];
+
+type StringTuple3Array StringTuple3[];
+
+type StringTuple4Array StringTuple4[];
+
+type AnydataTuple3Array AnydataTuple3[];
+
+type JsonTuple3Array JsonTuple3[];
+
+type IntegerArray1Array IntegerArray1[];
+
+type IntegerArray2Array IntegerArray2[];
+
+type IntegerArray3Array IntegerArray3[];
+
+type IntegerArray4Array IntegerArray4[];
+
+type IntegerArray5Array IntegerArray5[];
+
+type IntegerArray6Array IntegerArray5[];
+
+type StringArray1Array StringArray1[];
+
+type StringArrayArray StringArray[];
+
+type NillableStringArrayArray NillableStringArray[];
+
+type NillableIntOrUnionStringArrayArray NillableIntOrUnionStringArray[];
+
+type StringArray2Array StringArray2[];
+type DecimalArray1Array DecimalArray1[];
+
+type JsonArray1Array JsonArray1[];
+
+type AnydataArray1Array AnydataArray1[];
+
+type IntegerMapArray IntegerMap[];
+
+type StringMapArray StringMap[];
+
+type NillableIntUnionStringMapArray NillableIntUnionStringMap[];
+
+type IntUnionStringMapArray IntUnionStringMap[];
+
+type DecimalMapArray DecimalMap[];
+
+type BooleanMapArray BooleanMap[];
+
+type NilMapArray NilMap[];
+
+type JsonMapArray JsonMap[];
+
+type AnydataMapArray AnydataMap[];
+
+type CustomMapArray CustomMap[];
diff --git a/ballerina-tests/parse-record-types-tests/Ballerina.toml b/ballerina-tests/parse-record-types-tests/Ballerina.toml
new file mode 100644
index 0000000..7cdb2d4
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/Ballerina.toml
@@ -0,0 +1,16 @@
+[package]
+org = "ballerina"
+name = "parse_record_types_tests"
+version = "0.1.0"
+
+[[dependency]]
+org = "ballerina"
+name = "csv_commons"
+repository = "local"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
+
+[build-options]
+graalvmBuildOptions = "-H:+IncludeAllLocales"
diff --git a/ballerina-tests/parse-record-types-tests/Dependencies.toml b/ballerina-tests/parse-record-types-tests/Dependencies.toml
new file mode 100644
index 0000000..54bfd11
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/Dependencies.toml
@@ -0,0 +1,98 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.9.0"
+
+[[package]]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+scope = "testOnly"
+modules = [
+ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"}
+]
+
+[[package]]
+org = "ballerina"
+name = "data.csv"
+version = "0.1.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "data.csv", moduleName = "data.csv"}
+]
+
+[[package]]
+org = "ballerina"
+name = "jballerina.java"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "lang.__internal"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.object"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.array"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.__internal"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.error"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.object"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "parse_record_types_tests"
+version = "0.1.0"
+dependencies = [
+ {org = "ballerina", name = "csv_commons"},
+ {org = "ballerina", name = "data.csv"},
+ {org = "ballerina", name = "test"}
+]
+modules = [
+ {org = "ballerina", packageName = "parse_record_types_tests", moduleName = "parse_record_types_tests"}
+]
+
+[[package]]
+org = "ballerina"
+name = "test"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.array"},
+ {org = "ballerina", name = "lang.error"}
+]
+modules = [
+ {org = "ballerina", packageName = "test", moduleName = "test"}
+]
+
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
new file mode 100644
index 0000000..51a1840
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_list_test.bal
@@ -0,0 +1,682 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvWithTypeForMapAndArrayAsExpectedType() {
+ BooleanArrayArray|csv:Error bm1ba = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, BooleanArrayArray);
+ test:assertEquals(bm1ba, [
+ [true, false],
+ [true, false]
+ ]);
+
+ bm1ba = csv:transform([bm1, bm1], {headerOrder: ["b2", "b1"]}, BooleanArrayArray);
+ test:assertEquals(bm1ba, [
+ [false, true],
+ [false, true]
+ ]);
+
+ BooleanArrayArray|csv:Error bm2ba = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, BooleanArrayArray);
+ test:assertTrue(bm2ba is csv:Error);
+ test:assertEquals((bm2ba).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanArrayArray|csv:Error bm3ba = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, BooleanArrayArray);
+ test:assertTrue(bm3ba is csv:Error);
+ test:assertEquals((bm3ba).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanArrayArray|csv:Error bm4ba = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, BooleanArrayArray);
+ test:assertTrue(bm4ba is csv:Error);
+ test:assertEquals((bm4ba).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "boolean"));
+
+ BooleanArrayArray|csv:Error bm5ba = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, BooleanArrayArray);
+ test:assertTrue(bm5ba is csv:Error);
+ test:assertEquals((bm5ba).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ NillableBooleanArrayArray|csv:Error bm1nba = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm1nba, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error bm2nba = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm2nba, [
+ [true, false, null, null, null],
+ [true, false, null, null, null]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error bm3nba = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableBooleanArrayArray);
+ test:assertTrue(bm3nba is csv:Error);
+ test:assertEquals((bm3nba).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "4", "boolean?"));
+
+ NillableBooleanArrayArray|csv:Error bm4nba = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm4nba, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error bm5nba = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm5nba, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ bm5nba = csv:transform([bm5, bm5], {headerOrder: ["b1", "b3", "b2", "b4"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm5nba, [
+ [true, (), false, true],
+ [true, (), false, true]
+ ]);
+
+ bm5nba = csv:transform([bm5, bm5], {headerOrder: ["b4", "b3", "b2", "b1"]}, NillableBooleanArrayArray);
+ test:assertEquals(bm5nba, [
+ [true, (), false, true],
+ [true, (), false, true]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error bm1niouba = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableIntOrUnionBooleanArrayArray);
+ test:assertEquals(bm1niouba, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error bm2niouba = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableIntOrUnionBooleanArrayArray);
+ test:assertEquals(bm2niouba, [
+ [true, false, null, null, null],
+ [true, false, null, null, null]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error bm3niouba = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableIntOrUnionBooleanArrayArray);
+ test:assertEquals(bm3niouba, [
+ [true, false, null, false, 1],
+ [true, false, null, false, 1]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error bm4niouba = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableIntOrUnionBooleanArrayArray);
+ test:assertEquals(bm4niouba, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error bm5niouba = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableIntOrUnionBooleanArrayArray);
+ test:assertEquals(bm5niouba, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ JsonArray1Array|csv:Error bm1ja = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, JsonArray1Array);
+ test:assertEquals(bm1ja, [
+ [true, false],
+ [true, false]
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndArrayAsExpectedType2() {
+ JsonArray1Array|csv:Error bm2ja = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, JsonArray1Array);
+ test:assertEquals(bm2ja, [
+ [true, false, null, null, null],
+ [true, false, null, null, null]
+ ]);
+
+ JsonArray1Array|csv:Error bm3ja = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, JsonArray1Array);
+ test:assertEquals(bm3ja, [
+ [true, false, null, false, 1],
+ [true, false, null, false, 1]
+ ]);
+
+ JsonArray1Array|csv:Error bm4ja = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, JsonArray1Array);
+ test:assertEquals(bm4ja, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ JsonArray1Array|csv:Error bm5ja = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, JsonArray1Array);
+ test:assertEquals(bm5ja, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ AnydataArray1Array|csv:Error bm1anyda = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, AnydataArray1Array);
+ test:assertEquals(bm1anyda, [
+ [true, false],
+ [true, false]
+ ]);
+
+ AnydataArray1Array|csv:Error bm2anyda = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, AnydataArray1Array);
+ test:assertEquals(bm2anyda, [
+ [true, false, null, null, null],
+ [true, false, null, null, null]
+ ]);
+
+ AnydataArray1Array|csv:Error bm3anyda = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, AnydataArray1Array);
+ test:assertEquals(bm3anyda, [
+ [true, false, null, false, 1],
+ [true, false, null, false, 1]
+ ]);
+
+ AnydataArray1Array|csv:Error bm4anyda = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, AnydataArray1Array);
+ test:assertEquals(bm4anyda, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ AnydataArray1Array|csv:Error bm5anyda = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, AnydataArray1Array);
+ test:assertEquals(bm5anyda, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ StringArray1Array|csv:Error bm1sa = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, StringArray1Array);
+ test:assertTrue(bm1sa is csv:Error);
+ test:assertEquals((bm1sa).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringArray1Array|csv:Error bm2sa = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, StringArray1Array);
+ test:assertTrue(bm2sa is csv:Error);
+ test:assertEquals((bm2sa).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringArray1Array|csv:Error bm3sa = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, StringArray1Array);
+ test:assertTrue(bm3sa is csv:Error);
+ test:assertEquals((bm3sa).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringArray1Array|csv:Error bm4sa = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, StringArray1Array);
+ test:assertTrue(bm4sa is csv:Error);
+ test:assertEquals((bm4sa).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "string"));
+
+ StringArray1Array|csv:Error bm5sa = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, StringArray1Array);
+ test:assertTrue(bm5sa is csv:Error);
+ test:assertEquals((bm5sa).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndTupleAsExpectedType() {
+ BooleanTuple1Array|csv:Error bm1bt = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, BooleanTuple1Array);
+ test:assertEquals(bm1bt, [
+ [true, false, false, false],
+ [true, false, false, false]
+ ]);
+
+ BooleanTuple1Array|csv:Error bm2bt = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, BooleanTuple1Array);
+ test:assertTrue(bm2bt is csv:Error);
+ test:assertEquals((bm2bt).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple1Array|csv:Error bm3bt = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, BooleanTuple1Array);
+ test:assertTrue(bm3bt is csv:Error);
+ test:assertEquals((bm3bt).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple1Array|csv:Error bm4bt = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, BooleanTuple1Array);
+ test:assertTrue(bm4bt is csv:Error);
+ test:assertEquals((bm4bt).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "boolean"));
+
+ BooleanTuple1Array|csv:Error bm5bt = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, BooleanTuple1Array);
+ test:assertTrue(bm5bt is csv:Error);
+ test:assertEquals((bm5bt).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple2Array|csv:Error bm1b2t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, BooleanTuple2Array);
+ test:assertEquals(bm1b2t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple2Array|csv:Error bm2b2t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, BooleanTuple2Array);
+ test:assertEquals(bm2b2t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple2Array|csv:Error bm3b2t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, BooleanTuple2Array);
+ test:assertEquals(bm3b2t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple2Array|csv:Error bm4b2t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, BooleanTuple2Array);
+ test:assertTrue(bm4b2t is csv:Error);
+ test:assertEquals((bm4b2t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "boolean"));
+
+ BooleanTuple2Array|csv:Error bm5b2t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, BooleanTuple2Array);
+ test:assertEquals(bm5b2t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple3Array|csv:Error bm1b3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, BooleanTuple3Array);
+ test:assertEquals(bm1b3t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple3Array|csv:Error bm2b3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, BooleanTuple3Array);
+ test:assertTrue(bm2b3t is csv:Error);
+ test:assertEquals((bm2b3t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple3Array|csv:Error bm3b3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, BooleanTuple3Array);
+ test:assertTrue(bm3b3t is csv:Error);
+ test:assertEquals((bm3b3t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple3Array|csv:Error bm4b3t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, BooleanTuple3Array);
+ test:assertTrue(bm4b3t is csv:Error);
+ test:assertEquals((bm4b3t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "boolean"));
+
+ BooleanTuple3Array|csv:Error bm5b3t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, BooleanTuple3Array);
+ test:assertTrue(bm5b3t is csv:Error);
+ test:assertEquals((bm5b3t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple4Array|csv:Error bm1b4t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, BooleanTuple4Array);
+ test:assertEquals(bm1b4t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple4Array|csv:Error bm2b4t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, BooleanTuple4Array);
+ test:assertTrue(bm2b4t is csv:Error);
+ test:assertEquals((bm2b4t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndTupleAsExpectedType2() {
+ BooleanTuple4Array|csv:Error bm3b4t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, BooleanTuple4Array);
+ test:assertTrue(bm3b4t is csv:Error);
+ test:assertEquals((bm3b4t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ BooleanTuple4Array|csv:Error bm4b4t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, BooleanTuple4Array);
+ test:assertTrue(bm4b4t is csv:Error);
+ test:assertEquals((bm4b4t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "boolean"));
+
+ BooleanTuple4Array|csv:Error bm5b4t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, BooleanTuple4Array);
+ test:assertTrue(bm5b4t is csv:Error);
+ test:assertEquals((bm5b4t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "2", "boolean"));
+
+ NillableBooleanTuple5Array|csv:Error bm1nbt = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableBooleanTuple5Array);
+ test:assertEquals(bm1nbt, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error bm2nbt = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableBooleanTuple5Array);
+ test:assertEquals(bm2nbt, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error bm3nbt = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableBooleanTuple5Array);
+ test:assertTrue(bm3nbt is csv:Error);
+ test:assertEquals((bm3nbt).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "4", "boolean?"));
+
+ NillableBooleanTuple5Array|csv:Error bm4nbt = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableBooleanTuple5Array);
+ test:assertEquals(bm4nbt, [
+ [(), (), (), (), ()],
+ [(), (), (), (), ()]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error bm5nbt = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableBooleanTuple5Array);
+ test:assertEquals(bm5nbt, [
+ [true, false, (), true, ()],
+ [true, false, (), true, ()]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error bm1nb6t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableBooleanTuple6Array);
+ test:assertEquals(bm1nb6t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error bm2nb6t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableBooleanTuple6Array);
+ test:assertEquals(bm2nb6t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error bm3nb6t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableBooleanTuple6Array);
+ test:assertEquals(bm3nb6t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error bm4nb6t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableBooleanTuple6Array);
+ test:assertEquals(bm4nb6t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error bm5nb6t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableBooleanTuple6Array);
+ test:assertEquals(bm5nb6t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error bm1nb7t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableBooleanTuple7Array);
+ test:assertEquals(bm1nb7t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error bm2nb7t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableBooleanTuple7Array);
+ test:assertEquals(bm2nb7t, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error bm3nb7t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableBooleanTuple7Array);
+ test:assertTrue(bm3nb7t is csv:Error);
+ test:assertEquals((bm3nb7t).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "4", "boolean?"));
+
+ NillableBooleanTuple7Array|csv:Error bm4nb7t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableBooleanTuple7Array);
+ test:assertEquals(bm4nb7t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error bm5nb7t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableBooleanTuple7Array);
+ test:assertEquals(bm5nb7t, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndTupleAsExpectedType3() {
+ NillableBooleanTuple8Array|csv:Error bm1nb8t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableBooleanTuple8Array);
+ test:assertEquals(bm1nb8t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error bm2nb8t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableBooleanTuple8Array);
+ test:assertEquals(bm2nb8t, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error bm3nb8t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableBooleanTuple8Array);
+ test:assertTrue(bm3nb8t is csv:Error);
+ test:assertEquals((bm3nb8t).message(), common:generateErrorMessageForInvalidValueForArrayType("1", "4", "boolean?"));
+
+ NillableBooleanTuple8Array|csv:Error bm4nb8t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableBooleanTuple8Array);
+ test:assertEquals(bm4nb8t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error bm5nb8t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableBooleanTuple8Array);
+ test:assertEquals(bm5nb8t, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error bm1nb9t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NillableIntBooleanTuple9Array);
+ test:assertEquals(bm1nb9t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error bm2nb9t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NillableIntBooleanTuple9Array);
+ test:assertEquals(bm2nb9t, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error bm3nb9t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NillableIntBooleanTuple9Array);
+ test:assertEquals(bm3nb9t, [
+ [true, false, (), false, 1],
+ [true, false, (), false, 1]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error bm4nb9t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NillableIntBooleanTuple9Array);
+ test:assertEquals(bm4nb9t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error bm5nb9t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NillableIntBooleanTuple9Array);
+ test:assertEquals(bm5nb9t, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ NilTuple3Array|csv:Error bm1n3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, NilTuple3Array);
+ test:assertTrue(bm1n3t is csv:Error);
+ test:assertEquals((bm1n3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "()"));
+
+ NilTuple3Array|csv:Error bm2n3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, NilTuple3Array);
+ test:assertTrue(bm2n3t is csv:Error);
+ test:assertEquals((bm2n3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "()"));
+
+ NilTuple3Array|csv:Error bm3n3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, NilTuple3Array);
+ test:assertTrue(bm3n3t is csv:Error);
+ test:assertEquals((bm3n3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "()"));
+
+ NilTuple3Array|csv:Error bm4n3t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, NilTuple3Array);
+ test:assertEquals(bm4n3t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ NilTuple3Array|csv:Error bm5n3t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, NilTuple3Array);
+ test:assertTrue(bm5n3t is csv:Error);
+ test:assertEquals((bm5n3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "()"));
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndArrayAsExpectedType3() {
+
+ AnydataTuple3Array|csv:Error bm1anyd3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"], outputWithHeaders: false}, AnydataTuple3Array);
+ test:assertEquals(bm1anyd3t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm2anyd3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, AnydataTuple3Array);
+ test:assertEquals(bm2anyd3t, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm3anyd3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, AnydataTuple3Array);
+ test:assertEquals(bm3anyd3t, [
+ [true, false, (), false, 1],
+ [true, false, (), false, 1]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm4anyd3t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"], outputWithHeaders: false}, AnydataTuple3Array);
+ test:assertEquals(bm4anyd3t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm5anyd3t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, AnydataTuple3Array);
+ test:assertEquals(bm5anyd3t, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ JsonTuple3Array|csv:Error bm1j3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, JsonTuple3Array);
+ test:assertEquals(bm1j3t, [
+ [true, false],
+ [true, false]
+ ]);
+
+ JsonTuple3Array|csv:Error bm2j3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, JsonTuple3Array);
+ test:assertEquals(bm2j3t, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ JsonTuple3Array|csv:Error bm3j3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, JsonTuple3Array);
+ test:assertEquals(bm3j3t, [
+ [true, false, (), false, 1],
+ [true, false, (), false, 1]
+ ]);
+
+ JsonTuple3Array|csv:Error bm4j3t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, JsonTuple3Array);
+ test:assertEquals(bm4j3t, [
+ [(), ()],
+ [(), ()]
+ ]);
+
+ JsonTuple3Array|csv:Error bm5j3t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, JsonTuple3Array);
+ test:assertEquals(bm5j3t, [
+ [true, false, (), true],
+ [true, false, (), true]
+ ]);
+
+ StringTuple3Array|csv:Error bm1s3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"]}, StringTuple3Array);
+ test:assertTrue(bm1s3t is csv:Error);
+ test:assertEquals((bm1s3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringTuple3Array|csv:Error bm2s3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"]}, StringTuple3Array);
+ test:assertTrue(bm2s3t is csv:Error);
+ test:assertEquals((bm2s3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringTuple3Array|csv:Error bm3s3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"]}, StringTuple3Array);
+ test:assertTrue(bm3s3t is csv:Error);
+ test:assertEquals((bm3s3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+
+ StringTuple3Array|csv:Error bm4s3t = csv:transform([bm4, bm4], {headerOrder: ["n1", "n3"]}, StringTuple3Array);
+ test:assertTrue(bm4s3t is csv:Error);
+ test:assertEquals((bm4s3t).message(), common:generateErrorMessageForInvalidValueForArrayType("null", "0", "string"));
+
+ StringTuple3Array|csv:Error bm5s3t = csv:transform([bm5, bm5], {headerOrder: ["b1", "b2", "b3", "b4"]}, StringTuple3Array);
+ test:assertTrue(bm5s3t is csv:Error);
+ test:assertEquals((bm5s3t).message(), common:generateErrorMessageForInvalidValueForArrayType("true", "0", "string"));
+}
+
+@test:Config
+function testArrayIndexes() {
+ map[] csv = [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}, {a: 7, b: 8}];
+
+ int[][2]|csv:Error rec3 = csv:transform(csv, {headerOrder: ["a", "b"]});
+ test:assertEquals(rec3, [
+ [1, 2],
+ [3, 4],
+ [5, 6],
+ [7, 8]
+ ]);
+
+ [int...][2]|csv:Error rec3_3 = csv:transform(csv, {headerOrder: ["a", "b"], skipLines: [1]});
+ test:assertEquals(rec3_3, [
+ [3, 4],
+ [5, 6]
+ ]);
+
+ int[1][2]|csv:Error rec4 = csv:transform(csv, {headerOrder: ["a", "b"], skipLines: [2]});
+ test:assertEquals(rec4, [
+ [1, 2]
+ ]);
+}
+
+@test:Config
+function testParseRecordsAsListsWithHeaderOutput() {
+ AnydataTuple3Array|csv:Error bm1anyd3t = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"], outputWithHeaders: true});
+ test:assertEquals(bm1anyd3t, [
+ ["b1", "b2"],
+ [true, false],
+ [true, false]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm2anyd3t = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"], outputWithHeaders: true});
+ test:assertEquals(bm2anyd3t, [
+ ["b1", "b2", "b3", "n1", "n3"],
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ AnydataTuple3Array|csv:Error bm3anyd3t = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"], outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t, [
+ ["b1", "b2", "b3", "b4", "i1"],
+ [true, false, (), false, 1],
+ [true, false, (), false, 1]
+ ]);
+
+ anydata[][]|csv:Error bm1anyd3t_2 = csv:transform([bm1, bm1], {headerOrder: ["b1", "b2"], outputWithHeaders: true});
+ test:assertEquals(bm1anyd3t_2, [
+ ["b1", "b2"],
+ [true, false],
+ [true, false]
+ ]);
+
+ anydata[][]|csv:Error bm2anyd3t_2 = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"], outputWithHeaders: true});
+ test:assertEquals(bm2anyd3t_2, [
+ ["b1", "b2", "b3", "n1", "n3"],
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ anydata[2][3]|csv:Error bm3anyd3t_2 = csv:transform([bm3, bm3], {headerOrder: ["b1", "b2", "b3", "b4", "i1"], outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t_2, [
+ ["b1", "b2", "b3"],
+ [true, false, ()]
+ ]);
+
+ anydata[][]|csv:Error bm2anyd3t_3 = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n1", "n3"], outputWithHeaders: false});
+ test:assertEquals(bm2anyd3t_3, [
+ [true, false, (), (), ()],
+ [true, false, (), (), ()]
+ ]);
+
+ anydata[][]|csv:Error bm2anyd3t_4 = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n2", "n3"], outputWithHeaders: false});
+ test:assertTrue(bm2anyd3t_4 is csv:Error);
+ test:assertEquals(( bm2anyd3t_4).message(), "CSV data rows with varying headers are not yet supported");
+
+ bm2anyd3t_4 = csv:transform([bm2, bm2], {headerOrder: ["b1", "b2", "b3", "n2", "n3"], outputWithHeaders: true});
+ test:assertTrue(bm2anyd3t_4 is csv:Error);
+ test:assertEquals(( bm2anyd3t_4).message(), "CSV data rows with varying headers are not yet supported");
+}
+
+@test:Config
+function testsRecordsOutputWithHeadrs() {
+ anydata[2][3]|csv:Error bm3anyd3t_2 = csv:transform([bm3, bm3], {outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t_2, [
+ ["b1", "b2", "b3"],
+ [true, false, ()]
+ ]);
+
+ anydata[][]|csv:Error bm3anyd3t_3 = csv:transform([bm3, bm3], {outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t_3, [
+ ["b1", "b2", "b3", "b4", "i1"],
+ [true, false, (), false, 1],
+ [true, false, (), false, 1]
+ ]);
+
+ bm3anyd3t_3 = csv:transform([{"a": 1, "b": 2}, {"a": 3, "b": 4}], {outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t_3, [
+ ["a", "b"],
+ [1, 2],
+ [3, 4]
+ ]);
+
+ bm3anyd3t_3 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}], {outputWithHeaders: true});
+ test:assertTrue(bm3anyd3t_3 is csv:Error);
+ test:assertEquals(( bm3anyd3t_3).message(), "CSV data rows with varying headers are not yet supported");
+
+ bm3anyd3t_3 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}], {outputWithHeaders: false});
+ test:assertTrue(bm3anyd3t_3 is csv:Error);
+ test:assertEquals(( bm3anyd3t_3).message(), "CSV data rows with varying headers are not yet supported");
+
+ record {}[]|csv:Error bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"a": 3, "b": 4}]);
+ test:assertEquals(bm3anyd3t_4, [{"a": 1, "b": 2}, {"a": 3, "b": 4}]);
+
+ bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}]);
+ test:assertEquals(bm3anyd3t_4, [{"a": 1, "b": 2}, {"c": 3, "d": 4}]);
+
+ bm3anyd3t_3 = csv:parseList([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true});
+ test:assertEquals(bm3anyd3t_3, [["a", "b"], ["c", "d", "e"]]);
+
+ bm3anyd3t_4 = csv:parseList([["a", "b"], ["c", "d", "e"]]);
+ 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/parse-record-types-tests/tests/parse_record_type_as_record_test.bal b/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_record_test.bal
new file mode 100644
index 0000000..172ec9d
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/tests/parse_record_type_as_record_test.bal
@@ -0,0 +1,769 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvWithTypeForMapAndRecordAsExpectedType() {
+ BooleanRecord1Array|csv:Error bm1br1 = csv:transform([bm1, bm1], {}, BooleanRecord1Array);
+ test:assertTrue(bm1br1 is csv:Error);
+ test:assertEquals((bm1br1).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord1Array|csv:Error bm2br1 = csv:transform([bm2, bm2], {}, BooleanRecord1Array);
+ test:assertTrue(bm2br1 is csv:Error);
+ test:assertEquals((bm2br1).message(), common:generateErrorMessageForMissingRequiredField("b4"));
+
+ BooleanRecord1Array|csv:Error bm3br1 = csv:transform([bm3, bm3], {}, BooleanRecord1Array);
+ test:assertEquals(bm3br1, [
+ {b1: true, b2: false, b3: (), b4: false, i1: 1},
+ {b1: true, b2: false, b3: (), b4: false, i1: 1}
+ ]);
+
+ BooleanRecord1Array|csv:Error bm4br1 = csv:transform([bm4, bm4], {}, BooleanRecord1Array);
+ test:assertTrue(bm4br1 is csv:Error);
+ test:assertEquals((bm4br1).message(), common:generateErrorMessageForMissingRequiredField("b2"));
+
+ BooleanRecord1Array|csv:Error bm5br1 = csv:transform([bm5, bm5], {}, BooleanRecord1Array);
+ test:assertEquals(bm5br1, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ BooleanRecord2Array|csv:Error bm1br2 = csv:transform([bm1, bm1], {}, BooleanRecord2Array);
+ test:assertTrue(bm1br2 is csv:Error);
+ test:assertEquals((bm1br2).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord2Array|csv:Error bm2br2 = csv:transform([bm2, bm2], {}, BooleanRecord2Array);
+ test:assertTrue(bm2br2 is csv:Error);
+ test:assertEquals((bm2br2).message(), common:generateErrorMessageForMissingRequiredField("b4"));
+
+ BooleanRecord2Array|csv:Error bm3br2 = csv:transform([bm3, bm3], {}, BooleanRecord2Array);
+ test:assertEquals(bm3br2, [
+ {b1: true, b2: false, b3: (), b4: false},
+ {b1: true, b2: false, b3: (), b4: false}
+ ]);
+
+ BooleanRecord2Array|csv:Error bm4br2 = csv:transform([bm4, bm4], {}, BooleanRecord2Array);
+ test:assertTrue(bm4br2 is csv:Error);
+ test:assertEquals((bm4br2).message(), common:generateErrorMessageForMissingRequiredField("b2"));
+
+ BooleanRecord2Array|csv:Error bm5br2 = csv:transform([bm5, bm5], {}, BooleanRecord2Array);
+ test:assertEquals(bm5br2, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ BooleanRecord3Array|csv:Error bm1br3 = csv:transform([bm1, bm1], {}, BooleanRecord3Array);
+ test:assertTrue(bm1br3 is csv:Error);
+ test:assertEquals((bm1br3).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord3Array|csv:Error bm2br3 = csv:transform([bm2, bm2], {}, BooleanRecord3Array);
+ test:assertEquals(bm2br3, [
+ {b1: true, b3: ()},
+ {b1: true, b3: ()}
+ ]);
+
+ BooleanRecord3Array|csv:Error bm3br3 = csv:transform([bm3, bm3], {}, BooleanRecord3Array);
+ test:assertEquals(bm3br3, [
+ {b1: true, b3: ()},
+ {b1: true, b3: ()}
+ ]);
+
+ BooleanRecord3Array|csv:Error bm4br3 = csv:transform([bm4, bm4], {}, BooleanRecord3Array);
+ test:assertTrue(bm4br3 is csv:Error);
+ test:assertEquals((bm4br3).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord3Array|csv:Error bm5br3 = csv:transform([bm5, bm5], {}, BooleanRecord3Array);
+ test:assertEquals(bm5br3, [{b1: true, b3: ()}, {b1: true, b3: ()}]);
+
+ BooleanRecord4Array|csv:Error bm1br4 = csv:transform([bm1, bm1], {}, BooleanRecord4Array);
+ test:assertTrue(bm1br4 is csv:Error);
+ test:assertEquals((bm1br4).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord4Array|csv:Error bm2br4 = csv:transform([bm2, bm2], {}, BooleanRecord4Array);
+ test:assertEquals(bm2br4, [
+ {b1: true, b2: false, b3: (), n1: (), n3: ()},
+ {b1: true, b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ BooleanRecord4Array|csv:Error bm3br4 = csv:transform([bm3, bm3], {}, BooleanRecord4Array);
+ test:assertEquals(bm3br4, [
+ {b1: true, b2: false, b3: (), b4: false, i1: 1},
+ {b1: true, b2: false, b3: (), b4: false, i1: 1}
+ ]);
+
+ BooleanRecord4Array|csv:Error bm4br4 = csv:transform([bm4, bm4], {}, BooleanRecord4Array);
+ test:assertTrue(bm4br4 is csv:Error);
+ test:assertEquals((bm4br4).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord4Array|csv:Error bm5br4 = csv:transform([bm5, bm5], {}, BooleanRecord4Array);
+ test:assertEquals(bm5br4, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ BooleanRecord5Array|csv:Error bm1br5 = csv:transform([bm1, bm1], {}, BooleanRecord5Array);
+ test:assertTrue(bm1br5 is csv:Error);
+ test:assertEquals((bm1br5).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord5Array|csv:Error bm2br5 = csv:transform([bm2, bm2], {}, BooleanRecord5Array);
+ test:assertEquals(bm2br5, [
+ {b1: true, b3: (), defaultableField: "", nillableField: (), b2: false, n1: (), n3: ()},
+ {b1: true, b3: (), defaultableField: "", nillableField: (), b2: false, n1: (), n3: ()}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndRecordAsExpectedType2() {
+ BooleanRecord5Array|csv:Error bm3br5 = csv:transform([bm3, bm3], {}, BooleanRecord5Array);
+ test:assertEquals(bm3br5, [
+ {b1: true, b3: (), defaultableField: "", nillableField: (), b2: false, i1: 1, b4: false},
+ {b1: true, b3: (), defaultableField: "", nillableField: (), b2: false, i1: 1, b4: false}
+ ]);
+
+ BooleanRecord5Array|csv:Error bm4br5 = csv:transform([bm4, bm4], {}, BooleanRecord5Array);
+ test:assertTrue(bm4br5 is csv:Error);
+ test:assertEquals((bm4br5).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord5Array|csv:Error bm5br5 = csv:transform([bm5, bm5], {}, BooleanRecord5Array);
+ test:assertEquals(bm5br5, [
+ {b1: true, b2: false, b3: (), b4: true, defaultableField: "", nillableField: ()},
+ {b1: true, b2: false, b3: (), b4: true, defaultableField: "", nillableField: ()}
+ ]);
+
+ BooleanRecord6Array|csv:Error bm1br6 = csv:transform([bm1, bm1], {}, BooleanRecord6Array);
+ test:assertTrue(bm1br6 is csv:Error);
+ test:assertEquals((bm1br6).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord6Array|csv:Error bm2br6 = csv:transform([bm2, bm2], {}, BooleanRecord6Array);
+ test:assertEquals(bm2br6, [
+ {b1: true, b3: (), defaultableField: "", nillableField: ()},
+ {b1: true, b3: (), defaultableField: "", nillableField: ()}
+ ]);
+
+ BooleanRecord6Array|csv:Error bm3br6 = csv:transform([bm3, bm3], {}, BooleanRecord6Array);
+ test:assertEquals(bm3br6, [
+ {b1: true, b3: (), defaultableField: "", nillableField: ()},
+ {b1: true, b3: (), defaultableField: "", nillableField: ()}
+ ]);
+
+ BooleanRecord6Array|csv:Error bm4br6 = csv:transform([bm4, bm4], {}, BooleanRecord6Array);
+ test:assertTrue(bm4br6 is csv:Error);
+ test:assertEquals((bm4br6).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord6Array|csv:Error bm5br6 = csv:transform([bm5, bm5], {}, BooleanRecord6Array);
+ test:assertEquals(bm5br6, [
+ {b1: true, b3: (), defaultableField: "", nillableField: ()},
+ {b1: true, b3: (), defaultableField: "", nillableField: ()}
+ ]);
+
+ BooleanRecord7Array|csv:Error bm1br7 = csv:transform([bm1, bm1], {}, BooleanRecord7Array);
+ test:assertTrue(bm1br7 is csv:Error);
+ test:assertEquals((bm1br7).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord7Array|csv:Error bm2br7 = csv:transform([bm2, bm2], {}, BooleanRecord7Array);
+ test:assertTrue(bm2br7 is csv:Error);
+ test:assertEquals((bm2br7).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord7Array|csv:Error bm3br7 = csv:transform([bm3, bm3], {}, BooleanRecord7Array);
+ test:assertTrue(bm3br7 is csv:Error);
+ test:assertEquals((bm3br7).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord7Array|csv:Error bm4br7 = csv:transform([bm4, bm4], {}, BooleanRecord7Array);
+ test:assertTrue(bm4br7 is csv:Error);
+ test:assertEquals((bm4br7).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord7Array|csv:Error bm5br7 = csv:transform([bm5, bm5], {}, BooleanRecord7Array);
+ test:assertTrue(bm5br7 is csv:Error);
+ test:assertEquals((bm5br7).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord8Array|csv:Error bm1br8 = csv:transform([bm1, bm1], {}, BooleanRecord8Array);
+ test:assertTrue(bm1br8 is csv:Error);
+ test:assertEquals((bm1br8).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord8Array|csv:Error bm2br8 = csv:transform([bm2, bm2], {}, BooleanRecord8Array);
+ test:assertTrue(bm2br8 is csv:Error);
+ test:assertEquals((bm2br8).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord8Array|csv:Error bm3br8 = csv:transform([bm3, bm3], {}, BooleanRecord8Array);
+ test:assertTrue(bm3br8 is csv:Error);
+ test:assertEquals((bm3br8).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord8Array|csv:Error bm4br8 = csv:transform([bm4, bm4], {}, BooleanRecord8Array);
+ test:assertTrue(bm4br8 is csv:Error);
+ test:assertEquals((bm4br8).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord8Array|csv:Error bm5br8 = csv:transform([bm5, bm5], {}, BooleanRecord8Array);
+ test:assertTrue(bm5br8 is csv:Error);
+ test:assertEquals((bm5br8).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndRecordAsExpectedType3() {
+ BooleanRecord9Array|csv:Error bm1br9 = csv:transform([bm1, bm1], {}, BooleanRecord9Array);
+ test:assertTrue(bm1br9 is csv:Error);
+ test:assertEquals((bm1br9).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord9Array|csv:Error bm2br9 = csv:transform([bm2, bm2], {}, BooleanRecord9Array);
+ test:assertEquals(bm2br9, [
+ {b1: true, b2: false, b3: (), n1: (), n3: ()},
+ {b1: true, b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ BooleanRecord9Array|csv:Error bm3br9 = csv:transform([bm3, bm3], {}, BooleanRecord9Array);
+ test:assertEquals(bm3br9, [
+ {b1: true, b2: false, b3: (), b4: false},
+ {b1: true, b2: false, b3: (), b4: false}
+ ]);
+
+ BooleanRecord9Array|csv:Error bm4br9 = csv:transform([bm4, bm4], {}, BooleanRecord9Array);
+ test:assertTrue(bm4br9 is csv:Error);
+ test:assertEquals((bm4br9).message(), common:generateErrorMessageForMissingRequiredField("b3"));
+
+ BooleanRecord9Array|csv:Error bm5br9 = csv:transform([bm5, bm5], {}, BooleanRecord9Array);
+ test:assertEquals(bm5br9, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ BooleanRecord10Array|csv:Error bm1br10 = csv:transform([bm1, bm1], {}, BooleanRecord10Array);
+ test:assertEquals(bm1br10, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ BooleanRecord10Array|csv:Error bm2br10 = csv:transform([bm2, bm2], {}, BooleanRecord10Array);
+ test:assertEquals(bm2br10, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ BooleanRecord10Array|csv:Error bm3br10 = csv:transform([bm3, bm3], {}, BooleanRecord10Array);
+ test:assertEquals(bm3br10, [
+ {b1: true, b2: false, b4: false},
+ {b1: true, b2: false, b4: false}
+ ]);
+
+ BooleanRecord10Array|csv:Error bm4br10 = csv:transform([bm4, bm4], {}, BooleanRecord10Array);
+ test:assertEquals(bm4br10, [
+ {},
+ {}
+ ]);
+
+ BooleanRecord10Array|csv:Error bm5br10 = csv:transform([bm5, bm5], {}, BooleanRecord10Array);
+ test:assertEquals(bm5br10, [
+ {b1: true, b2: false, b4: true},
+ {b1: true, b2: false, b4: true}
+ ]);
+
+ BooleanRecord11Array|csv:Error bm1br11 = csv:transform([bm1, bm1], {}, BooleanRecord11Array);
+ test:assertEquals(bm1br11, [
+ {b1: true, b2: false, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord11Array|csv:Error bm2br11 = csv:transform([bm2, bm2], {}, BooleanRecord11Array);
+ test:assertEquals(bm2br11, [
+ {b1: true, b2: false, b3: (), n1: (), n3: (), defaultableField: "", nillableField :null},
+ {b1: true, b2: false, b3: (), n1: (), n3: (), defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord11Array|csv:Error bm3br11 = csv:transform([bm3, bm3], {}, BooleanRecord11Array);
+ test:assertEquals(bm3br11, [
+ {b1: true, b2: false, b3: (), b4: false, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, b3: (), b4: false, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord11Array|csv:Error bm4br11 = csv:transform([bm4, bm4], {}, BooleanRecord11Array);
+ test:assertTrue(bm4br11 is csv:Error);
+ test:assertEquals((bm4br11).message(), common:generateErrorMessageForMissingRequiredField("b1"));
+
+ BooleanRecord11Array|csv:Error bm5br11 = csv:transform([bm5, bm5], {}, BooleanRecord11Array);
+ test:assertEquals(bm5br11, [
+ {b1: true, b2: false, b3: (), b4: true, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, b3: (), b4: true, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord12Array|csv:Error bm1br12 = csv:transform([bm1, bm1], {}, BooleanRecord12Array);
+ test:assertTrue(bm1br12 is csv:Error);
+ test:assertEquals((bm1br12).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord12Array|csv:Error bm2br12 = csv:transform([bm2, bm2], {}, BooleanRecord12Array);
+ test:assertTrue(bm2br12 is csv:Error);
+ test:assertEquals((bm2br12).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord12Array|csv:Error bm3br12 = csv:transform([bm3, bm3], {}, BooleanRecord12Array);
+ test:assertTrue(bm3br12 is csv:Error);
+ test:assertEquals((bm3br12).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord12Array|csv:Error bm4br12 = csv:transform([bm4, bm4], {}, BooleanRecord12Array);
+ test:assertTrue(bm4br12 is csv:Error);
+ test:assertEquals((bm4br12).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord12Array|csv:Error bm5br12 = csv:transform([bm5, bm5], {}, BooleanRecord12Array);
+ test:assertTrue(bm5br12 is csv:Error);
+ test:assertEquals((bm5br12).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord13Array|csv:Error bm1br13 = csv:transform([bm1, bm1], {}, BooleanRecord13Array);
+ test:assertEquals(bm1br13, [
+ {b1: true, b2: false, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord13Array|csv:Error bm2br13 = csv:transform([bm2, bm2], {}, BooleanRecord13Array);
+ test:assertEquals(bm2br13, [
+ {b1: true, b2: false, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord13Array|csv:Error bm3br13 = csv:transform([bm3, bm3], {}, BooleanRecord13Array);
+ test:assertEquals(bm3br13, [
+ {b1: true, b2: false, b4: false, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, b4: false, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord13Array|csv:Error bm4br13 = csv:transform([bm4, bm4], {}, BooleanRecord13Array);
+ test:assertEquals(bm4br13, [
+ {defaultableField: "", nillableField :null},
+ {defaultableField: "", nillableField :null}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndRecordAsExpectedType4() {
+ BooleanRecord13Array|csv:Error bm5br13 = csv:transform([bm5, bm5], {}, BooleanRecord13Array);
+ test:assertEquals(bm5br13, [
+ {b1: true, b2: false, b4: true, defaultableField: "", nillableField :null},
+ {b1: true, b2: false, b4: true, defaultableField: "", nillableField :null}
+ ]);
+
+ BooleanRecord14Array|csv:Error bm1br14 = csv:transform([bm1, bm1], {}, BooleanRecord14Array);
+ test:assertTrue(bm1br14 is csv:Error);
+ test:assertEquals((bm1br14).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord14Array|csv:Error bm2br14 = csv:transform([bm2, bm2], {}, BooleanRecord14Array);
+ test:assertTrue(bm2br14 is csv:Error);
+ test:assertEquals((bm2br14).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord14Array|csv:Error bm3br14 = csv:transform([bm3, bm3], {}, BooleanRecord14Array);
+ test:assertTrue(bm3br14 is csv:Error);
+ test:assertEquals((bm3br14).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord14Array|csv:Error bm4br14 = csv:transform([bm4, bm4], {}, BooleanRecord14Array);
+ test:assertTrue(bm4br14 is csv:Error);
+ test:assertEquals((bm4br14).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord14Array|csv:Error bm5br14 = csv:transform([bm5, bm5], {}, BooleanRecord14Array);
+ test:assertTrue(bm5br14 is csv:Error);
+ test:assertEquals((bm5br14).message(), common:generateErrorMessageForMissingRequiredField("requiredField"));
+
+ BooleanRecord15Array|csv:Error bm1br15 = csv:transform([bm1, bm1], {}, BooleanRecord15Array);
+ test:assertTrue(bm1br15 is csv:Error);
+ test:assertEquals((bm1br15).message(), common:generateErrorMessageForInvalidFieldType("true", "b1"));
+
+ BooleanRecord15Array|csv:Error bm3br15 = csv:transform([bm3, bm3], {}, BooleanRecord15Array);
+ test:assertTrue(bm3br15 is csv:Error);
+ test:assertEquals((bm3br15).message(), common:generateErrorMessageForInvalidFieldType("true", "b1"));
+
+ BooleanRecord15Array|csv:Error bm4br15 = csv:transform([bm4, bm4], {}, BooleanRecord15Array);
+ test:assertTrue(bm4br15 is csv:Error);
+ test:assertEquals((bm4br15).message(), common:generateErrorMessageForMissingRequiredField("b1"));
+
+ BooleanRecord16Array|csv:Error bm1br16 = csv:transform([bm1, bm1], {}, BooleanRecord16Array);
+ test:assertEquals(bm1br16, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ BooleanRecord16Array|csv:Error bm2br16 = csv:transform([bm2, bm2], {}, BooleanRecord16Array);
+ test:assertEquals(bm2br16, [
+ {b1: true, b2: false, b3: (), n1: (), n3: ()},
+ {b1: true, b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ BooleanRecord16Array|csv:Error bm3br16 = csv:transform([bm3, bm3], {}, BooleanRecord16Array);
+ test:assertEquals(bm3br16, [
+ {b1: true, b2: false, b4: false, b3: ()},
+ {b1: true, b2: false, b4: false, b3: ()}
+ ]);
+
+ BooleanRecord16Array|csv:Error bm4br16 = csv:transform([bm4, bm4], {}, BooleanRecord16Array);
+ test:assertEquals(bm4br16, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+
+ BooleanRecord16Array|csv:Error bm5br16 = csv:transform([bm5, bm5], {}, BooleanRecord16Array);
+ test:assertEquals(bm5br16, [
+ {b1: true, b2: false, b4: true, b3: ()},
+ {b1: true, b2: false, b4: true, b3: ()}
+ ]);
+
+ BooleanRecord17Array|csv:Error bm1br17 = csv:transform([bm1, bm1], {}, BooleanRecord17Array);
+ test:assertEquals(bm1br17, [
+ {},
+ {}
+ ]);
+
+ BooleanRecord17Array|csv:Error bm2br17 = csv:transform([bm2, bm2], {}, BooleanRecord17Array);
+ test:assertEquals(bm2br17, [
+ {},
+ {}
+ ]);
+
+ BooleanRecord17Array|csv:Error bm3br17 = csv:transform([bm3, bm3], {}, BooleanRecord17Array);
+ test:assertEquals(bm3br17, [
+ {i1: 1},
+ {i1: 1}
+ ]);
+
+ BooleanRecord17Array|csv:Error bm4br17 = csv:transform([bm4, bm4], {}, BooleanRecord17Array);
+ test:assertEquals(bm4br17, [
+ {},
+ {}
+ ]);
+
+ BooleanRecord17Array|csv:Error bm5br17 = csv:transform([bm5, bm5], {}, BooleanRecord17Array);
+ test:assertEquals(bm5br17, [
+ {},
+ {}
+ ]);
+
+ BooleanRecord18Array|csv:Error bm1br18 = csv:transform([bm1, bm1], {}, BooleanRecord18Array);
+ test:assertEquals(bm1br18, [
+ {b2: false},
+ {b2: false}
+ ]);
+
+ BooleanRecord18Array|csv:Error bm2br18 = csv:transform([bm2, bm2], {}, BooleanRecord18Array);
+ test:assertEquals(bm2br18, [
+ {b2: false, b3: (), n1: (), n3: ()},
+ {b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ BooleanRecord18Array|csv:Error bm3br18 = csv:transform([bm3, bm3], {}, BooleanRecord18Array);
+ test:assertEquals(bm3br18, [
+ {b2: false, b3: (), i1: 1},
+ {b2: false, b3: (), i1: 1}
+ ]);
+
+ BooleanRecord18Array|csv:Error bm4br18 = csv:transform([bm4, bm4], {}, BooleanRecord18Array);
+ test:assertTrue(bm4br18 is csv:Error);
+ test:assertEquals((bm4br18).message(), common:generateErrorMessageForMissingRequiredField("b2"));
+
+ BooleanRecord18Array|csv:Error bm5br18 = csv:transform([bm5, bm5], {}, BooleanRecord18Array);
+ test:assertEquals(bm5br18, [
+ {b2: false, b3: ()},
+ {b2: false, b3: ()}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndMapAsExpectedType() {
+ BooleanMapArray|csv:Error bm1bma = csv:transform([bm1, bm1], {}, BooleanMapArray);
+ test:assertEquals(bm1bma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ BooleanMapArray|csv:Error bm2bma = csv:transform([bm2, bm2], {}, BooleanMapArray);
+ test:assertEquals(bm2bma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ BooleanMapArray|csv:Error bm3bma = csv:transform([bm3, bm3], {}, BooleanMapArray);
+ test:assertEquals(bm3bma, [
+ {b1: true, b2: false, b4: false},
+ {b1: true, b2: false, b4: false}
+ ]);
+
+ BooleanMapArray|csv:Error bm4bma = csv:transform([bm4, bm4], {}, BooleanMapArray);
+ test:assertEquals(bm4bma, [
+ {},
+ {}
+ ]);
+
+ BooleanMapArray|csv:Error bm5bma = csv:transform([bm5, bm5], {}, BooleanMapArray);
+ test:assertEquals(bm5bma, [
+ {b1: true, b2: false, b4: true},
+ {b1: true, b2: false, b4: true}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bm1nbma = csv:transform([bm1, bm1], {}, NillableBooleanMapArray);
+ test:assertEquals(bm1nbma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bm2nbma = csv:transform([bm2, bm2], {}, NillableBooleanMapArray);
+ test:assertEquals(bm2nbma, [
+ {b1: true, b2: false, b3:(), n1: (), n3: ()},
+ {b1: true, b2: false, b3:(), n1: (), n3: ()}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bm3nbma = csv:transform([bm3, bm3], {}, NillableBooleanMapArray);
+ test:assertEquals(bm3nbma, [
+ {b1: true, b2: false, b3:(), b4: false},
+ {b1: true, b2: false, b3:(), b4: false}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bm4nbma = csv:transform([bm4, bm4], {}, NillableBooleanMapArray);
+ test:assertEquals(bm4nbma, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bm5nbma = csv:transform([bm5, bm5], {}, NillableBooleanMapArray);
+ test:assertEquals(bm5nbma, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bm1niubma = csv:transform([bm1, bm1], {}, NillableIntUnionBooleanMapArray);
+ test:assertEquals(bm1niubma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bm2niubma = csv:transform([bm2, bm2], {}, NillableIntUnionBooleanMapArray);
+ test:assertEquals(bm2niubma, [
+ {b1: true, b2: false, b3:(), n1: (), n3: ()},
+ {b1: true, b2: false, b3:(), n1: (), n3: ()}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bm3niubma = csv:transform([bm3, bm3], {}, NillableIntUnionBooleanMapArray);
+ test:assertEquals(bm3niubma, [
+ {b1: true, b2: false, b3:(), b4: false, i1: 1},
+ {b1: true, b2: false, b3:(), b4: false, i1: 1}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bm4niubma = csv:transform([bm4, bm4], {}, NillableIntUnionBooleanMapArray);
+ test:assertEquals(bm4niubma, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bm5niubma = csv:transform([bm5, bm5], {}, NillableIntUnionBooleanMapArray);
+ test:assertEquals(bm5niubma, [
+ {b1: true, b2: false, b3: (), b4: true},
+ {b1: true, b2: false, b3: (), b4: true}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bm1iubma = csv:transform([bm1, bm1], {}, IntUnionBooleanMapArray);
+ test:assertEquals(bm1iubma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bm2iubma = csv:transform([bm2, bm2], {}, IntUnionBooleanMapArray);
+ test:assertEquals(bm2iubma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bm3iubma = csv:transform([bm3, bm3], {}, IntUnionBooleanMapArray);
+ test:assertEquals(bm3iubma, [
+ {b1: true, b2: false, b4: false, i1: 1},
+ {b1: true, b2: false, b4: false, i1: 1}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bm4iubma = csv:transform([bm4, bm4], {}, IntUnionBooleanMapArray);
+ test:assertEquals(bm4iubma, [
+ {},
+ {}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bm5iubma = csv:transform([bm5, bm5], {}, IntUnionBooleanMapArray);
+ test:assertEquals(bm5iubma, [
+ {b1: true, b2: false, b4: true},
+ {b1: true, b2: false, b4: true}
+ ]);
+
+ NilMapArray|csv:Error bm1nma = csv:transform([bm1, bm1], {}, NilMapArray);
+ test:assertEquals(bm1nma, [
+ {},
+ {}
+ ]);
+
+ NilMapArray|csv:Error bm2nma = csv:transform([bm2, bm2], {}, NilMapArray);
+ test:assertEquals(bm2nma, [
+ {n1: (), n3: (), b3: ()},
+ {n1: (), n3: (), b3: ()}
+ ]);
+}
+
+@test:Config
+function testFromCsvWithTypeForMapAndMapAsExpectedType2() {
+ NilMapArray|csv:Error bm3nma = csv:transform([bm3, bm3], {}, NilMapArray);
+ test:assertEquals(bm3nma, [
+ {b3: ()},
+ {b3: ()}
+ ]);
+
+ NilMapArray|csv:Error bm4nma = csv:transform([bm4, bm4], {}, NilMapArray);
+ test:assertEquals(bm4nma, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+ NilMapArray|csv:Error bm5nma = csv:transform([bm5, bm5], {}, NilMapArray);
+ test:assertEquals(bm5nma, [
+ {b3: ()},
+ {b3: ()}
+ ]);
+
+ JsonMapArray|csv:Error bm1jma = csv:transform([bm1, bm1], {}, JsonMapArray);
+ test:assertEquals(bm1jma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ JsonMapArray|csv:Error bm2jma = csv:transform([bm2, bm2], {}, JsonMapArray);
+ test:assertEquals(bm2jma, [
+ {b1: true, b2: false, b3: (), n1: (), n3: ()},
+ {b1: true, b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ JsonMapArray|csv:Error bm3jma = csv:transform([bm3, bm3], {}, JsonMapArray);
+ test:assertEquals(bm3jma, [
+ {b1: true, b2: false, b4: false, b3: (), i1: 1},
+ {b1: true, b2: false, b4: false, b3: (), i1: 1}
+ ]);
+
+ JsonMapArray|csv:Error bm4jma = csv:transform([bm4, bm4], {}, JsonMapArray);
+ test:assertEquals(bm4jma, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+
+ JsonMapArray|csv:Error bm5jma = csv:transform([bm5, bm5], {}, JsonMapArray);
+ test:assertEquals(bm5jma, [
+ {b1: true, b2: false, b4: true, b3: ()},
+ {b1: true, b2: false, b4: true, b3: ()}
+ ]);
+
+ AnydataMapArray|csv:Error bm1anydma = csv:transform([bm1, bm1], {}, AnydataMapArray);
+ test:assertEquals(bm1anydma, [
+ {b1: true, b2: false},
+ {b1: true, b2: false}
+ ]);
+
+ AnydataMapArray|csv:Error bm2anydma = csv:transform([bm2, bm2], {}, AnydataMapArray);
+ test:assertEquals(bm2anydma, [
+ {b1: true, b2: false, b3: (), n1: (), n3: ()},
+ {b1: true, b2: false, b3: (), n1: (), n3: ()}
+ ]);
+
+ AnydataMapArray|csv:Error bm3anydma = csv:transform([bm3, bm3], {}, AnydataMapArray);
+ test:assertEquals(bm3anydma, [
+ {b1: true, b2: false, b4: false, b3: (), i1: 1},
+ {b1: true, b2: false, b4: false, b3: (), i1: 1}
+ ]);
+
+ AnydataMapArray|csv:Error bm4anydma = csv:transform([bm4, bm4], {}, AnydataMapArray);
+ test:assertEquals(bm4anydma, [
+ {n1: (), n3: ()},
+ {n1: (), n3: ()}
+ ]);
+
+ AnydataMapArray|csv:Error bm5anydma = csv:transform([bm5, bm5], {}, AnydataMapArray);
+ test:assertEquals(bm5anydma, [
+ {b1: true, b2: false, b4: true, b3: ()},
+ {b1: true, b2: false, b4: true, b3: ()}
+ ]);
+
+ CustomMapArray|csv:Error bm1cma = csv:transform([bm1, bm1], {}, CustomMapArray);
+ test:assertEquals(bm1cma, [
+ {},
+ {}
+ ]);
+
+ CustomMapArray|csv:Error bm2cma = csv:transform([bm2, bm2], {}, CustomMapArray);
+ test:assertEquals(bm2cma, [
+ {},
+ {}
+ ]);
+
+ CustomMapArray|csv:Error bm3cma = csv:transform([bm3, bm3], {}, CustomMapArray);
+ test:assertEquals(bm3cma, [
+ {i1: 1},
+ {i1: 1}
+ ]);
+
+ CustomMapArray|csv:Error bm4cma = csv:transform([bm4, bm4], {}, CustomMapArray);
+ test:assertEquals(bm4cma, [
+ {},
+ {}
+ ]);
+
+ CustomMapArray|csv:Error bm5cma = csv:transform([bm5, bm5], {}, CustomMapArray);
+ test:assertEquals(bm5cma, [
+ {},
+ {}
+ ]);
+
+ StringMapArray|csv:Error bm1sma = csv:transform([bm1, bm1], {}, StringMapArray);
+ test:assertEquals(bm1sma, [
+ {},
+ {}
+ ]);
+
+ StringMapArray|csv:Error bm2sma = csv:transform([bm2, bm2], {}, StringMapArray);
+ test:assertEquals(bm2sma, [
+ {},
+ {}
+ ]);
+
+ StringMapArray|csv:Error bm3sma = csv:transform([bm3, bm3], {}, StringMapArray);
+ test:assertEquals(bm3sma, [
+ {},
+ {}
+ ]);
+
+ StringMapArray|csv:Error bm4sma = csv:transform([bm4, bm4], {}, StringMapArray);
+ test:assertEquals(bm4sma, [
+ {},
+ {}
+ ]);
+
+ StringMapArray|csv:Error bm5sma = csv:transform([bm5, bm5], {}, StringMapArray);
+ test:assertEquals(bm5sma, [
+ {},
+ {}
+ ]);
+}
+
+@test:Config
+function testArrayIndexesInRecords() {
+ map[] csv = [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}, {a: 7, b: 8}];
+
+ record {}[2]|csv:Error rec = csv:transform(csv);
+ test:assertEquals(rec, [
+ {a: 1, b: 2},
+ {a: 3, b: 4}
+ ]);
+
+ record {|int a;|}[2]|csv:Error rec2 = csv:transform(csv, {skipLines: [2]});
+ test:assertEquals(rec2, [
+ {a: 1},
+ {a: 5}
+ ]);
+
+ record {|int a;|}[5]|csv:Error rec2_2 = csv:transform(csv, {skipLines: [2]});
+ test:assertTrue(rec2_2 is csv:Error);
+}
\ No newline at end of file
diff --git a/ballerina-tests/parse-record-types-tests/tests/test_data_values.bal b/ballerina-tests/parse-record-types-tests/tests/test_data_values.bal
new file mode 100644
index 0000000..547a3cb
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/tests/test_data_values.bal
@@ -0,0 +1,31 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+final boolean b1 = true;
+final false b2 = false;
+final boolean? b3 = ();
+final boolean|int b4 = false;
+
+final () n1 = ();
+final int? n2 = ();
+final () n3 = null;
+
+final int i1 = 1;
+final map bm1 = {b1, b2};
+final map bm2 = {b1, b2, b3, n1, n3};
+final map bm3 = {b1, b2, b3, b4, i1};
+final map<()> bm4 = {n1, n3};
+final map bm5 = {b1, b2, b3, b4:true};
diff --git a/ballerina-tests/parse-record-types-tests/tests/types.bal b/ballerina-tests/parse-record-types-tests/tests/types.bal
new file mode 100644
index 0000000..1d0a8ba
--- /dev/null
+++ b/ballerina-tests/parse-record-types-tests/tests/types.bal
@@ -0,0 +1,377 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+type BooleanRecord1 record {
+ boolean b1;
+ boolean|string b2;
+ boolean|string? b3;
+ boolean b4;
+};
+
+type BooleanRecord2 record {|
+ boolean b1;
+ boolean|string b2;
+ boolean|string? b3;
+ boolean b4;
+|};
+
+type BooleanRecord3 record {|
+ boolean b1;
+ boolean? b3;
+|};
+
+type BooleanRecord4 record {
+ boolean b1;
+ boolean? b3;
+};
+
+type BooleanRecord5 record {
+ boolean b1;
+ boolean? b3;
+ string defaultableField = "";
+ string? nillableField = ();
+};
+
+type BooleanRecord6 record {|
+ boolean b1;
+ boolean? b3;
+ string defaultableField = "";
+ string? nillableField = ();
+|};
+
+type BooleanRecord7 record {
+ boolean b1;
+ boolean? b3;
+ string defaultableField = "";
+ string? nillableField = ();
+ string requiredField;
+};
+
+type BooleanRecord8 record {|
+ boolean b1;
+ boolean? b3;
+ string defaultableField = "";
+ string? nillableField = ();
+ string requiredField;
+|};
+
+type BooleanRecord9 record {|
+ boolean b1;
+ boolean? b3;
+ boolean?...;
+|};
+
+type BooleanRecord10 record {|
+ boolean...;
+|};
+
+type BooleanRecord11 record {|
+ boolean b1;
+ string defaultableField = "";
+ string? nillableField = ();
+ boolean?|string...;
+|};
+
+type BooleanRecord12 record {|
+ boolean b1;
+ string defaultableField = "";
+ string? nillableField = ();
+ string requiredField;
+ boolean...;
+|};
+
+type BooleanRecord13 record {|
+ string defaultableField = "";
+ string? nillableField = ();
+ string|boolean...;
+|};
+
+type BooleanRecord14 record {|
+ string defaultableField = "";
+ string? nillableField = ();
+ string requiredField;
+ boolean...;
+|};
+
+type BooleanRecord15 record {|
+ int b1;
+ string defaultableField = "";
+ string? nillableField = ();
+ boolean?...;
+|};
+
+type BooleanRecord16 record {|
+ boolean?...;
+|};
+
+type BooleanRecord17 record {|
+ int...;
+|};
+
+type BooleanRecord18 record {|
+ boolean b2;
+ int?...;
+|};
+
+type BooleanTuple1 [boolean, boolean, boolean, boolean];
+
+type BooleanTuple2 [boolean, boolean];
+
+type BooleanTuple3 [boolean, boolean...];
+
+type BooleanTuple4 [boolean...];
+
+type NillableBooleanTuple5 [boolean?, boolean?, boolean?, boolean?, boolean?];
+
+type NillableBooleanTuple6 [boolean?, boolean?];
+
+type NillableBooleanTuple7 [boolean?, boolean?, boolean?...];
+
+type NillableBooleanTuple8 [boolean?...];
+
+type NillableIntBooleanTuple9 [int|boolean?, int|boolean?...];
+
+type NilTuple3 [(), ()...];
+
+type StringTuple3 [string, string...];
+
+type AnydataTuple3 [anydata, anydata...];
+
+type JsonTuple3 [json, json...];
+
+type StringArray string[];
+
+type StringArray1 string[];
+
+type BooleanArray boolean[];
+
+type NillableBooleanArray boolean?[];
+
+type NillableIntOrUnionBooleanArray (int|boolean?)[];
+
+type JsonArray1 json[];
+
+type AnydataArray1 anydata[];
+
+type IntegerMap map;
+
+type StringMap map;
+
+type NillableIntUnionStringMap map;
+
+type IntUnionStringMap map;
+
+type DecimalMap map;
+
+type FloatMap map;
+
+type BooleanMap map;
+
+type NillableBooleanMap map;
+
+type NillableIntUnionBooleanMap map;
+
+type IntUnionBooleanMap map;
+
+type NilMap map<()>;
+
+type JsonMap map;
+
+type AnydataMap map;
+
+type CustomMap map;
+
+type BooleanRecord1Array BooleanRecord1[];
+
+type ClosedBooleanRecord1Array BooleanRecord1[3];
+
+type BooleanRecord2Array BooleanRecord2[];
+
+type ClosedBooleanRecord2Array BooleanRecord2[3];
+
+type BooleanRecord3Array BooleanRecord3[];
+
+type ClosedBooleanRecord3Array BooleanRecord3[3];
+
+type BooleanRecord4Array BooleanRecord4[];
+
+type ClosedBooleanRecord4Array BooleanRecord4[3];
+
+type BooleanRecord5Array BooleanRecord5[];
+
+type ClosedBooleanRecord5Array BooleanRecord5[3];
+
+type BooleanRecord6Array BooleanRecord6[];
+
+type ClosedBooleanRecord6Array BooleanRecord6[3];
+
+type BooleanRecord7Array BooleanRecord7[];
+
+type ClosedBooleanRecord7Array BooleanRecord7[3];
+
+type BooleanRecord8Array BooleanRecord8[];
+
+type ClosedBooleanRecord8Array BooleanRecord8[3];
+
+type BooleanRecord9Array BooleanRecord9[];
+
+type ClosedBooleanRecord9Array BooleanRecord9[3];
+
+type BooleanRecord10Array BooleanRecord10[];
+
+type ClosedBooleanRecord10Array BooleanRecord10[3];
+
+type BooleanRecord11Array BooleanRecord11[];
+
+type ClosedBooleanRecord11Array BooleanRecord11[3];
+
+type BooleanRecord12Array BooleanRecord12[];
+
+type ClosedBooleanRecord12Array BooleanRecord12[3];
+
+type BooleanRecord13Array BooleanRecord13[];
+
+type ClosedBooleanRecord13Array BooleanRecord13[3];
+
+type BooleanRecord14Array BooleanRecord14[];
+
+type ClosedBooleanRecord14Array BooleanRecord14[3];
+
+type BooleanRecord15Array BooleanRecord15[];
+
+type ClosedBooleanRecord15Array BooleanRecord15[3];
+
+type BooleanRecord16Array BooleanRecord16[];
+
+type ClosedBooleanRecord16Array BooleanRecord16[3];
+
+type BooleanRecord17Array BooleanRecord17[];
+
+type ClosedBooleanRecord17Array BooleanRecord17[3];
+
+type BooleanRecord18Array BooleanRecord18[];
+
+type ClosedBooleanRecord18Array BooleanRecord18[3];
+
+type BooleanTuple1Array BooleanTuple1[];
+
+type ClosedBooleanTuple1Array BooleanTuple1[3];
+
+type BooleanTuple2Array BooleanTuple2[];
+
+type ClosedBooleanTuple2Array BooleanTuple2[3];
+
+type BooleanTuple3Array BooleanTuple3[];
+
+type ClosedBooleanTuple3Array BooleanTuple3[3];
+
+type BooleanTuple4Array BooleanTuple4[];
+
+type ClosedBooleanTuple4Array BooleanTuple4[3];
+
+type NillableBooleanTuple5Array NillableBooleanTuple5[];
+
+type NillableBooleanTuple6Array NillableBooleanTuple6[];
+
+type NillableBooleanTuple7Array NillableBooleanTuple7[];
+
+type NillableBooleanTuple8Array NillableBooleanTuple8[];
+
+type NillableIntBooleanTuple9Array NillableIntBooleanTuple9[];
+
+type NilTuple3Array NilTuple3[];
+
+type ClosedNilTuple3Array NilTuple3[3];
+
+type StringTuple3Array StringTuple3[];
+
+type ClosedStringTuple3Array StringTuple3[3];
+
+type AnydataTuple3Array AnydataTuple3[];
+
+type ClosedAnydataTuple3Array AnydataTuple3[3];
+
+type JsonTuple3Array JsonTuple3[];
+
+type ClosedJsonTuple3Array JsonTuple3[3];
+
+type StringArray1Array StringArray1[];
+
+type StringArrayArray StringArray[];
+
+type ClosedStringArray1Array StringArray1[3];
+
+type BooleanArrayArray BooleanArray[];
+
+type ClosedBooleanArrayArray BooleanArray[3];
+
+type NillableBooleanArrayArray NillableBooleanArray[];
+
+type NillableIntOrUnionBooleanArrayArray NillableIntOrUnionBooleanArray[];
+
+type JsonArray1Array JsonArray1[];
+
+type ClosedJsonArray1Array JsonArray1[3];
+
+type AnydataArray1Array AnydataArray1[];
+
+type ClosedAnydataArray1Array AnydataArray1[3];
+
+type IntegerMapArray IntegerMap[];
+
+type ClosedIntegerMapArray IntegerMap[3];
+
+type StringMapArray StringMap[];
+
+type NillableIntUnionStringMapArray NillableIntUnionStringMap[];
+
+type IntUnionStringMapArray IntUnionStringMap[];
+
+type ClosedStringMapArray StringMap[3];
+
+type DecimalMapArray DecimalMap[];
+
+type ClosedDecimalMapArray DecimalMap[3];
+
+type FloatMapArray FloatMap[];
+
+type ClosedFloatMapArray FloatMap[3];
+
+type BooleanMapArray BooleanMap[];
+
+type NillableBooleanMapArray NillableBooleanMap[];
+
+type NillableIntUnionBooleanMapArray NillableIntUnionBooleanMap[];
+
+type IntUnionBooleanMapArray IntUnionBooleanMap[];
+
+type ClosedBooleanMapArray BooleanMap[3];
+
+type NilMapArray NilMap[];
+
+type ClosedNilMapArray NilMap[3];
+
+type JsonMapArray JsonMap[];
+
+type ClosedJsonMapArray JsonMap[3];
+
+type AnydataMapArray AnydataMap[];
+
+type ClosedAnydataMapArray AnydataMap[3];
+
+type CustomMapArray CustomMap[];
+
+type ClosedCustomMapArray CustomMap[3];
diff --git a/ballerina-tests/parse-string-array-types-tests/Ballerina.toml b/ballerina-tests/parse-string-array-types-tests/Ballerina.toml
new file mode 100644
index 0000000..d1d42fe
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/Ballerina.toml
@@ -0,0 +1,16 @@
+[package]
+org = "ballerina"
+name = "parse_string_array_types_tests"
+version = "0.1.0"
+
+[[dependency]]
+org = "ballerina"
+name = "csv_commons"
+repository = "local"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
+
+[build-options]
+graalvmBuildOptions = "-H:+IncludeAllLocales"
diff --git a/ballerina-tests/parse-string-array-types-tests/Dependencies.toml b/ballerina-tests/parse-string-array-types-tests/Dependencies.toml
new file mode 100644
index 0000000..e07bf86
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/Dependencies.toml
@@ -0,0 +1,98 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.10.0-20240801-104200-87df251c"
+
+[[package]]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+scope = "testOnly"
+modules = [
+ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"}
+]
+
+[[package]]
+org = "ballerina"
+name = "data.csv"
+version = "0.1.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "data.csv", moduleName = "data.csv"}
+]
+
+[[package]]
+org = "ballerina"
+name = "jballerina.java"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "lang.__internal"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.object"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.array"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.__internal"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.error"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.object"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "parse_string_array_types_tests"
+version = "0.1.0"
+dependencies = [
+ {org = "ballerina", name = "csv_commons"},
+ {org = "ballerina", name = "data.csv"},
+ {org = "ballerina", name = "test"}
+]
+modules = [
+ {org = "ballerina", packageName = "parse_string_array_types_tests", moduleName = "parse_string_array_types_tests"}
+]
+
+[[package]]
+org = "ballerina"
+name = "test"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.array"},
+ {org = "ballerina", name = "lang.error"}
+]
+modules = [
+ {org = "ballerina", packageName = "test", moduleName = "test"}
+]
+
diff --git a/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_array_test.bal b/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_array_test.bal
new file mode 100644
index 0000000..96612e2
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_array_test.bal
@@ -0,0 +1,480 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndArrayAsExpectedType() {
+ BooleanArrayArray|csv:Error cv1baa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1baa, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ BooleanArrayArray|csv:Error cv2baa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2baa, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ BooleanArrayArray|csv:Error cv3baa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cv3baa is csv:Error);
+ test:assertEquals((cv3baa).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanArrayArray|csv:Error cv4baa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertTrue(cv4baa is csv:Error);
+ test:assertEquals((cv4baa).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanArrayArray|csv:Error cv5baa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cv5baa is csv:Error);
+ test:assertEquals((cv5baa).message(), common:generateErrorMessageForInvalidCast("2", "boolean"));
+
+ BooleanArrayArray|csv:Error cv6baa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertTrue(cv6baa is csv:Error);
+ test:assertEquals((cv6baa).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanArrayArray|csv:Error cv7baa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertTrue(cv7baa is csv:Error);
+ test:assertEquals((cv7baa).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ NillableBooleanArrayArray|csv:Error cv1nbaa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1nbaa, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error cv2nbaa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2nbaa, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error cv3nbaa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3nbaa, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error cv4nbaa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4nbaa, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error cv5nbaa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cv5nbaa is csv:Error);
+ test:assertEquals((cv5nbaa).message(), common:generateErrorMessageForInvalidCast("2", "boolean?"));
+
+ NillableBooleanArrayArray|csv:Error cv6nbaa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6nbaa, [
+ [(), ()]
+ ]);
+
+ NillableBooleanArrayArray|csv:Error cv7nbaa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7nbaa, [
+ [b1, b2, (), b4]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv1niubaa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1niubaa, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv2niubaa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2niubaa, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv3niubaa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3niubaa, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv4niubaa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4niubaa, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv5niubaa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cv5niubaa, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndArrayAsExpectedType2() {
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv6niubaa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6niubaa, [
+ [(), ()]
+ ]);
+
+ NillableIntOrUnionBooleanArrayArray|csv:Error cv7niubaa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7niubaa, [
+ [b1, b2, (), b4]
+ ]);
+
+ StringArray1Array|csv:Error cv1saa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1saa, [
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"]
+ ]);
+
+ StringArray1Array|csv:Error cv2saa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2saa, [
+ ["true", "false", "true", "false", "true"],
+ ["true", "false", "true", "false", "true"]
+ ]);
+
+ StringArray1Array|csv:Error cv3saa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3saa, [
+ ["true", "false", "true"],
+ ["TRUE", "FALSE", "()"],
+ ["true", "true", "FALSE"]
+ ]);
+
+ StringArray1Array|csv:Error cv4saa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4saa, [
+ ["true", "()", "()", "false"],
+ ["true", "()", "null", "false"]
+ ]);
+
+ StringArray1Array|csv:Error cv5saa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cv5saa, [
+ ["true", "false", "true", "2"],
+ ["true", "false", "true", "3"]
+ ]);
+
+ StringArray1Array|csv:Error cv6saa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6saa, [
+ ["()", "()"]
+ ]);
+
+ StringArray1Array|csv:Error cv7saa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7saa, [
+ ["true", "false", "()", "false"]
+ ]);
+
+ StringArray2Array|csv:Error cv1s2aa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1s2aa, [
+ ["true", "false"],
+ ["true", "false"],
+ ["true", "false"]
+ ]);
+
+ StringArray2Array|csv:Error cv2s2aa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2s2aa, [
+ ["true", "false"],
+ ["true", "false"]
+ ]);
+
+ StringArray2Array|csv:Error cv3s2aa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3s2aa, [
+ ["true", "false"],
+ ["TRUE", "FALSE"],
+ ["true", "true"]
+ ]);
+
+ StringArray2Array|csv:Error cv4s2aa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4s2aa, [
+ ["true", "()"],
+ ["true", "()"]
+ ]);
+
+ StringArray2Array|csv:Error cv5s2aa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cv5s2aa, [
+ ["true", "false"],
+ ["true", "false"]
+ ]);
+
+ StringArray2Array|csv:Error cv6s2aa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6s2aa, [
+ ["()", "()"]
+ ]);
+
+ StringArray2Array|csv:Error cv7s2aa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7s2aa, [
+ ["true", "false"]
+ ]);
+
+ JsonArray1Array|csv:Error cv1jaa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1jaa, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndArrayAsExpectedType3() {
+ JsonArray1Array|csv:Error cv2jaa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2jaa, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ JsonArray1Array|csv:Error cv3jaa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3jaa, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ JsonArray1Array|csv:Error cv4jaa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4jaa, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ JsonArray1Array|csv:Error cv5jaa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cv5jaa, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+
+ JsonArray1Array|csv:Error cv6jaa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6jaa, [
+ [(), ()]
+ ]);
+
+ JsonArray1Array|csv:Error cv7jaa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7jaa, [
+ [b1, b2, (), b4]
+ ]);
+
+ AnydataArray1Array|csv:Error cv1anydaa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cv1anydaa, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ AnydataArray1Array|csv:Error cv2anydaa = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cv2anydaa, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ AnydataArray1Array|csv:Error cv3anydaa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cv3anydaa, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ AnydataArray1Array|csv:Error cv4anydaa = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cv4anydaa, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ AnydataArray1Array|csv:Error cv5anydaa = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cv5anydaa, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+
+ AnydataArray1Array|csv:Error cv6anydaa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cv6anydaa, [
+ [(), ()]
+ ]);
+
+ AnydataArray1Array|csv:Error cv7anydaa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cv7anydaa, [
+ [b1, b2, (), b4]
+ ]);
+
+ DecimalArray1Array|csv:Error cv1daa = csv:parseString(csvStringWithBooleanValues1);
+ test:assertTrue(cv1daa is csv:Error);
+ test:assertEquals((cv1daa).message(), common:generateErrorMessageForInvalidCast("true", "decimal"));
+
+ DecimalArray1Array|csv:Error cv3daa = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cv3daa is csv:Error);
+ test:assertEquals((cv3daa).message(), common:generateErrorMessageForInvalidCast("true", "decimal"));
+
+ DecimalArray1Array|csv:Error cv6daa = csv:parseString(csvStringWithBooleanValues6);
+ test:assertTrue(cv6daa is csv:Error);
+ test:assertEquals((cv6daa).message(), common:generateErrorMessageForInvalidCast("()", "decimal"));
+
+ DecimalArray1Array|csv:Error cv7daa = csv:parseString(csvStringWithBooleanValues7);
+ test:assertTrue(cv7daa is csv:Error);
+ test:assertEquals((cv7daa).message(), common:generateErrorMessageForInvalidCast("true", "decimal"));
+}
+
+@test:Config
+function testArrayIndexes() {
+ string csv = string `a, b
+ 1, 2
+ 3, 4
+ 5, 6
+ 7, 8`;
+
+ string csv2 = string `a, b
+ 1, 2, 3
+ 3, 4, 5
+ 5, 6, 7
+ 7, 8, 9`;
+
+ record {}[2]|csv:Error rec = csv:parseString(csv);
+ test:assertEquals(rec, [
+ {a: 1, b: 2},
+ {a: 3, b: 4}
+ ]);
+
+ map[2]|csv:Error rec_2 = csv:parseString(csv);
+ test:assertEquals(rec_2, [
+ {a: 1, b: 2},
+ {a: 3, b: 4}
+ ]);
+
+ record {|int a;|}[2]|csv:Error rec2 = csv:parseString(csv, {skipLines: [2]});
+ test:assertEquals(rec2, [
+ {a: 1},
+ {a: 5}
+ ]);
+
+ record {|int a;|}[5]|csv:Error rec2_2 = csv:parseString(csv, {skipLines: [2]});
+ test:assertTrue(rec2_2 is csv:Error);
+
+ int[][2]|csv:Error rec3 = csv:parseString(csv2);
+ test:assertEquals(rec3, [
+ [1, 2],
+ [3, 4],
+ [5, 6],
+ [7, 8]
+ ]);
+
+ [int, int][2]|csv:Error rec3_2 = csv:parseString(csv2);
+ test:assertEquals(rec3_2, [
+ [1, 2],
+ [3, 4]
+ ]);
+
+ [int...][2]|csv:Error rec3_3 = csv:parseString(csv2);
+ test:assertEquals(rec3_3, [
+ [1, 2, 3],
+ [3, 4, 5]
+ ]);
+
+ int[1][2]|csv:Error rec4 = csv:parseString(csv2, {skipLines: [2]});
+ test:assertEquals(rec4, [
+ [1, 2]
+ ]);
+
+ int[2][]|csv:Error rec5 = csv:parseString(csv2);
+ test:assertEquals(rec5, [
+ [1, 2, 3],
+ [3, 4, 5]
+ ]);
+}
+
+@test:Config
+function testParseStringArrayAsExpectedTypeWithOutputHeaders() {
+ BooleanArrayArray|csv:Error cv1baa = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true});
+ test:assertTrue(cv1baa is csv:Error);
+ test:assertEquals((cv1baa).message(), common:generateErrorMessageForInvalidCast("b1", "boolean"));
+
+ string[][]|csv:Error cv1baa_2 = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true});
+ test:assertEquals(cv1baa_2, [
+ ["b1", "b2", "b3", "b4"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"]
+ ]);
+
+ (boolean|string)[][]|csv:Error cv2baa = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ (string|boolean)[][]|csv:Error cv2baa_2 = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa_2, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ ["true", "false", "true", "false", "true"],
+ ["true", "false", "true", "false", "true"]
+ ]);
+
+ [string...][]|csv:Error cv2baa_2_2 = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa_2_2, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ ["true", "false", "true", "false", "true"],
+ ["true", "false", "true", "false", "true"]
+ ]);
+
+ [boolean|string...][]|csv:Error cv2baa_3 = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa_3, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ string[][]|csv:Error cv1baa_4 = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true});
+ test:assertEquals(cv1baa_4, [
+ ["b1", "b2", "b3", "b4"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"]
+ ]);
+
+ string[][]|csv:Error cv1baa_5 = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true, header: 2});
+ test:assertTrue(cv1baa_5 is csv:Error);
+ test:assertEquals((cv1baa_5).message(), "duplicate header found: 'true'");
+
+ string[][]|csv:Error cv1baa_6 = csv:parseString(csvStringWithBooleanValues8, {outputWithHeaders: false, header: 2});
+ test:assertEquals(cv1baa_6, [
+ ["true", "false", "true1", "false1"]
+ ]);
+
+ [string, string, string, string, string][]|csv:Error cv2baa_7 = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa_7, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ ["true", "false", "true", "false", "true"],
+ ["true", "false", "true", "false", "true"]
+ ]);
+
+ [boolean|string, boolean|string...][]|csv:Error cv2baa_8 = csv:parseString(csvStringWithBooleanValues2, {outputWithHeaders: true});
+ test:assertEquals(cv2baa_8, [
+ ["b1", "b2", "b3", "b4", "b5"],
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ string[2][2]|csv:Error cv1baa_9 = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true, header: ()});
+ test:assertEquals(cv1baa_9, [
+ ["b1", "b2"],
+ ["true", "false"]
+ ]);
+
+ cv1baa_9 = csv:parseString(csvStringWithBooleanValues1, {outputWithHeaders: true, header: null});
+ test:assertEquals(cv1baa_9, [
+ ["b1", "b2"],
+ ["true", "false"]
+ ]);
+}
diff --git a/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_tuple_test.bal b/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_tuple_test.bal
new file mode 100644
index 0000000..a43009d
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/tests/parse_string_to_tuple_test.bal
@@ -0,0 +1,488 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndTupleAsExpectedType() {
+ BooleanTuple1Array|csv:Error cbv1bt1 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt1, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ BooleanTuple1Array|csv:Error cbv2bt1 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt1, [
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ BooleanTuple1Array|csv:Error cbv3bt1 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cbv3bt1 is csv:Error);
+ test:assertEquals((cbv3bt1).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple1Array|csv:Error cbv5bt1 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt1 is csv:Error);
+ test:assertEquals((cbv5bt1).message(), common:generateErrorMessageForInvalidCast("2", "boolean"));
+
+ BooleanTuple1Array|csv:Error cbv7bt1 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertTrue(cbv7bt1 is csv:Error);
+ test:assertEquals((cbv7bt1).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple2Array|csv:Error cbv1bt2 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt2, [
+ [true, false],
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple2Array|csv:Error cbv2bt2 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt2, [
+ [true, false],
+ [true, false]
+ ]);
+
+ BooleanTuple2Array|csv:Error cbv3bt2 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt2, [
+ [true, false],
+ [true, false],
+ [true, true]
+ ]);
+
+ BooleanTuple2Array|csv:Error cbv4bt2 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertTrue(cbv4bt2 is csv:Error);
+ test:assertEquals((cbv4bt2).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple3Array|csv:Error cbv1bt3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt3, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ BooleanTuple3Array|csv:Error cbv2bt3 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt3, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ BooleanTuple3Array|csv:Error cbv3bt3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cbv3bt3 is csv:Error);
+ test:assertEquals((cbv3bt3).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple3Array|csv:Error cbv5bt3 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt3 is csv:Error);
+ test:assertEquals((cbv5bt3).message(), common:generateErrorMessageForInvalidCast("2", "boolean"));
+
+ BooleanTuple3Array|csv:Error cbv7bt3 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertTrue(cbv7bt3 is csv:Error);
+ test:assertEquals((cbv7bt3).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple4Array|csv:Error cbv1bt4 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt4, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ BooleanTuple4Array|csv:Error cbv2bt4 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt4, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ BooleanTuple4Array|csv:Error cbv3bt4 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cbv3bt4 is csv:Error);
+ test:assertEquals((cbv3bt4).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple4Array|csv:Error cbv4bt4 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertTrue(cbv4bt4 is csv:Error);
+ test:assertEquals((cbv4bt4).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ BooleanTuple4Array|csv:Error cbv5bt4 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt4 is csv:Error);
+ test:assertEquals((cbv5bt4).message(), common:generateErrorMessageForInvalidCast("2", "boolean"));
+
+ BooleanTuple4Array|csv:Error cbv6bt4 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertTrue(cbv6bt4 is csv:Error);
+ test:assertEquals((cbv6bt4).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndTupleAsExpectedType2() {
+ BooleanTuple4Array|csv:Error cbv7bt4 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertTrue(cbv7bt4 is csv:Error);
+ test:assertEquals((cbv7bt4).message(), common:generateErrorMessageForInvalidCast("()", "boolean"));
+
+ NillableBooleanTuple5Array|csv:Error cbv1bt5 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt5, [
+ [true, false, true, false, null],
+ [true, false, true, false, null],
+ [true, false, true, false, null]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error cbv2bt5 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt5, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error cbv3bt5 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt5, [
+ [true, false, true, null, null],
+ [true, false, (), null, null],
+ [true, true, false, null, null]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error cbv4bt5 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4bt5, [
+ [true, (), (), false, null],
+ [true, (), (), false, null]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error cbv5bt5 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt5 is csv:Error);
+ test:assertEquals((cbv5bt5).message(), common:generateErrorMessageForInvalidCast("2", "boolean?"));
+
+ NillableBooleanTuple5Array|csv:Error cbv6bt5 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6bt5, [
+ [(), (), null, null, null]
+ ]);
+
+ NillableBooleanTuple5Array|csv:Error cbv7bt5 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7bt5, [
+ [b1, b2, (), b4, null]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv1bt6 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt6, [
+ [true, false],
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv2bt6 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt6, [
+ [true, false],
+ [true, false]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv3bt6 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt6, [
+ [true, false],
+ [true, false],
+ [true, true]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv4bt6 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4bt6, [
+ [true, ()],
+ [true, ()]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv6bt6 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6bt6, [
+ [(), null]
+ ]);
+
+ NillableBooleanTuple6Array|csv:Error cbv7bt6 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7bt6, [
+ [b1, b2]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error cbv1bt7 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt7, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error cbv2bt7 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt7, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error cbv3bt7 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt7, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error cbv4bt7 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4bt7, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+}
+@test:Config
+function testFromCsvStringWithTypeForStringAndTupleAsExpectedType3() {
+ NillableBooleanTuple7Array|csv:Error cbv5bt7 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt7 is csv:Error);
+ test:assertEquals((cbv5bt7).message(), common:generateErrorMessageForInvalidCast("2", "boolean?"));
+
+ NillableBooleanTuple7Array|csv:Error cbv6bt7 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6bt7, [
+ [(), ()]
+ ]);
+
+ NillableBooleanTuple7Array|csv:Error cbv7bt7 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7bt7, [
+ [b1, b2, (), false]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv1bt8 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt8, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv2bt8 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt8, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv3bt8 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt8, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv4bt8 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4bt8, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv5bt8 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertTrue(cbv5bt8 is csv:Error);
+ test:assertEquals((cbv5bt8).message(), common:generateErrorMessageForInvalidCast("2", "boolean?"));
+
+ NillableBooleanTuple8Array|csv:Error cbv6bt8 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6bt8, [
+ [(), ()]
+ ]);
+
+ NillableBooleanTuple8Array|csv:Error cbv7bt8 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7bt8, [
+ [b1, b2, (), false]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv1bt9 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1bt9, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv2bt9 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2bt9, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv3bt9 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3bt9, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv4bt9 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4bt9, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv5bt9 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cbv5bt9, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv6bt9 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6bt9, [
+ [(), ()]
+ ]);
+
+ NillableIntBooleanTuple9Array|csv:Error cbv7bt9 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7bt9, [
+ [b1, b2, (), false]
+ ]);
+
+ NilTuple3Array|csv:Error cbv1nt3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertTrue(cbv1nt3 is csv:Error);
+ test:assertEquals((cbv1nt3).message(), common:generateErrorMessageForInvalidCast("true", "()"));
+
+ NilTuple3Array|csv:Error cbv3nt3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cbv3nt3 is csv:Error);
+ test:assertEquals((cbv3nt3).message(), common:generateErrorMessageForInvalidCast("true", "()"));
+
+ NilTuple3Array|csv:Error cbv6nt3 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6nt3, [
+ [(), ()]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv1anyd3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1anyd3, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv2anyd3 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2anyd3, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv3anyd3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3anyd3, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv4anyd3 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4anyd3, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv5anyd3 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cbv5anyd3, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv6anyd3 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6anyd3, [
+ [(), ()]
+ ]);
+
+ AnydataTuple3Array|csv:Error cbv7anyd3 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7anyd3, [
+ [b1, b2, (), false]
+ ]);
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndTupleAsExpectedType4() {
+ JsonTuple3Array|csv:Error cbv1j3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1j3, [
+ [true, false, true, false],
+ [true, false, true, false],
+ [true, false, true, false]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv2j3 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2j3, [
+ [true, false, true, false, true],
+ [true, false, true, false, true]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv3j3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3j3, [
+ [true, false, true],
+ [true, false, ()],
+ [true, true, false]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv4j3 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4j3, [
+ [true, (), (), false],
+ [true, (), (), false]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv5j3 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cbv5j3, [
+ [true, false, true, 2],
+ [true, false, true, 3]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv6j3 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6j3, [
+ [(), ()]
+ ]);
+
+ JsonTuple3Array|csv:Error cbv7j3 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7j3, [
+ [b1, b2, (), false]
+ ]);
+
+ StringTuple3Array|csv:Error cbv1s3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(cbv1s3, [
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"],
+ ["true", "false", "true", "false"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv2s3 = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(cbv2s3, [
+ ["true", "false", "true", "false", "true"],
+ ["true", "false", "true", "false", "true"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv3s3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(cbv3s3, [
+ ["true", "false", "true"],
+ ["TRUE", "FALSE", "()"],
+ ["true", "true", "FALSE"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv4s3 = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(cbv4s3, [
+ ["true", "()", "()", "false"],
+ ["true", "()", "null", "false"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv5s3 = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(cbv5s3, [
+ ["true", "false", "true", "2"],
+ ["true", "false", "true", "3"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv6s3 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(cbv6s3, [
+ ["()", "()"]
+ ]);
+
+ StringTuple3Array|csv:Error cbv7s3 = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(cbv7s3, [
+ ["true", "false", "()", "false"]
+ ]);
+
+ DecimalTuple3Array|csv:Error cbv1dt3 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertTrue(cbv1dt3 is csv:Error);
+ test:assertEquals((cbv1dt3).message(), common:generateErrorMessageForInvalidCast("true", "decimal"));
+
+ DecimalTuple3Array|csv:Error cbv3dt3 = csv:parseString(csvStringWithBooleanValues3);
+ test:assertTrue(cbv3dt3 is csv:Error);
+ test:assertEquals((cbv3dt3).message(), common:generateErrorMessageForInvalidCast("true", "decimal"));
+
+ DecimalTuple3Array|csv:Error cbv6dt3 = csv:parseString(csvStringWithBooleanValues6);
+ test:assertTrue(cbv6dt3 is csv:Error);
+ test:assertEquals((cbv6dt3).message(), common:generateErrorMessageForInvalidCast("()", "decimal"));
+}
diff --git a/ballerina-tests/parse-string-array-types-tests/tests/test_data_values.bal b/ballerina-tests/parse-string-array-types-tests/tests/test_data_values.bal
new file mode 100644
index 0000000..b39e526
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/tests/test_data_values.bal
@@ -0,0 +1,68 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+final boolean b1 = true;
+final false b2 = false;
+final boolean|int b4 = false;
+
+final string csvStringWithBooleanValues1 = string `b1,b2,b3,b4
+true,false,true,false
+true,false, true,false
+true,false,true,false
+`;
+
+final string csvStringWithBooleanValues2 = string `b1,b2,b3,b4,b5
+true,false, true,false,true
+true,false, true,false,true`;
+
+final string csvStringWithBooleanValues3 = string `b1,b2,b3
+${" "}${"\t"}
+true, false,true
+${" "}
+ TRUE, FALSE,()
+${" "}
+
+true, true,FALSE
+
+`;
+
+final string csvStringWithBooleanValues4 = string `b1,b2,b3,b4
+ true,(), (),false
+ true,(), null,false
+
+`;
+
+final string csvStringWithBooleanValues5 = string `b1,b2,b3,b4
+
+true,false,true,2
+
+true,false,true,3
+`;
+
+final string csvStringWithBooleanValues6 = string `b2,b3
+(),()
+
+`;
+
+final string csvStringWithBooleanValues7 = string `b1,b2,b3,b4
+${b1},${b2},(),${b4}
+`;
+
+final string csvStringWithBooleanValues8 = string `b1,b2,b3,b4
+true,false,true1,false1
+true,false, true1,false1
+true,false,true1,false1
+`;
diff --git a/ballerina-tests/parse-string-array-types-tests/tests/types.bal b/ballerina-tests/parse-string-array-types-tests/tests/types.bal
new file mode 100644
index 0000000..411b2b0
--- /dev/null
+++ b/ballerina-tests/parse-string-array-types-tests/tests/types.bal
@@ -0,0 +1,63 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+type BooleanArray boolean[];
+type BooleanArrayArray BooleanArray[];
+type NillableIntOrUnionBooleanArray (int|boolean?)[];
+type StringArray1 string[];
+type StringArray2 string[2];
+type JsonArray1 json[];
+type AnydataArray1 anydata[];
+type BooleanTuple1 [boolean, boolean, boolean, boolean];
+type BooleanTuple2 [boolean, boolean];
+type BooleanTuple3 [boolean, boolean...];
+type BooleanTuple4 [boolean...];
+type NillableBooleanTuple5 [boolean?, boolean?, boolean?, boolean?, boolean?];
+type NillableBooleanTuple6 [boolean?, boolean?];
+type NillableBooleanTuple7 [boolean?, boolean?, boolean?...];
+type NillableBooleanTuple8 [boolean?...];
+type NillableIntBooleanTuple9 [int|boolean?, int|boolean?...];
+type NilTuple3 [(), ()...];
+type DecimalTuple3 [decimal, decimal...];
+type StringTuple3 [string, string...];
+type AnydataTuple3 [anydata, anydata...];
+type JsonTuple3 [json, json...];
+type DecimalArray1 decimal[];
+
+type NilTuple3Array NilTuple3[];
+type DecimalTuple3Array DecimalTuple3[];
+type StringTuple3Array StringTuple3[];
+type AnydataTuple3Array AnydataTuple3[];
+type JsonTuple3Array JsonTuple3[];
+
+type NillableBooleanArray boolean?[];
+type NillableBooleanArrayArray NillableBooleanArray[];
+type NillableIntOrUnionBooleanArrayArray NillableIntOrUnionBooleanArray[];
+type StringArray1Array StringArray1[];
+type StringArray2Array StringArray2[];
+type JsonArray1Array JsonArray1[];
+type AnydataArray1Array AnydataArray1[];
+
+type BooleanTuple1Array BooleanTuple1[];
+type BooleanTuple2Array BooleanTuple2[];
+type BooleanTuple3Array BooleanTuple3[];
+type BooleanTuple4Array BooleanTuple4[];
+type NillableBooleanTuple5Array NillableBooleanTuple5[];
+type NillableBooleanTuple6Array NillableBooleanTuple6[];
+type NillableBooleanTuple7Array NillableBooleanTuple7[];
+type NillableBooleanTuple8Array NillableBooleanTuple8[];
+type NillableIntBooleanTuple9Array NillableIntBooleanTuple9[];
+type DecimalArray1Array DecimalArray1[];
diff --git a/ballerina-tests/parse-string-record-types-tests/Ballerina.toml b/ballerina-tests/parse-string-record-types-tests/Ballerina.toml
new file mode 100644
index 0000000..795eb35
--- /dev/null
+++ b/ballerina-tests/parse-string-record-types-tests/Ballerina.toml
@@ -0,0 +1,16 @@
+[package]
+org = "ballerina"
+name = "parse_string_record_types_tests"
+version = "0.1.0"
+
+[[dependency]]
+org = "ballerina"
+name = "csv_commons"
+repository = "local"
+version = "0.1.0"
+
+[platform.java17]
+graalvmCompatible = true
+
+[build-options]
+graalvmBuildOptions = "-H:+IncludeAllLocales"
diff --git a/ballerina-tests/parse-string-record-types-tests/Dependencies.toml b/ballerina-tests/parse-string-record-types-tests/Dependencies.toml
new file mode 100644
index 0000000..cf6d15e
--- /dev/null
+++ b/ballerina-tests/parse-string-record-types-tests/Dependencies.toml
@@ -0,0 +1,98 @@
+# AUTO-GENERATED FILE. DO NOT MODIFY.
+
+# This file is auto-generated by Ballerina for managing dependency versions.
+# It should not be modified by hand.
+
+[ballerina]
+dependencies-toml-version = "2"
+distribution-version = "2201.10.0-20240801-104200-87df251c"
+
+[[package]]
+org = "ballerina"
+name = "csv_commons"
+version = "0.1.0"
+scope = "testOnly"
+modules = [
+ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"}
+]
+
+[[package]]
+org = "ballerina"
+name = "data.csv"
+version = "0.1.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+modules = [
+ {org = "ballerina", packageName = "data.csv", moduleName = "data.csv"}
+]
+
+[[package]]
+org = "ballerina"
+name = "jballerina.java"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "lang.__internal"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.object"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.array"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.__internal"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.error"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"}
+]
+
+[[package]]
+org = "ballerina"
+name = "lang.object"
+version = "0.0.0"
+scope = "testOnly"
+
+[[package]]
+org = "ballerina"
+name = "parse_string_record_types_tests"
+version = "0.1.0"
+dependencies = [
+ {org = "ballerina", name = "csv_commons"},
+ {org = "ballerina", name = "data.csv"},
+ {org = "ballerina", name = "test"}
+]
+modules = [
+ {org = "ballerina", packageName = "parse_string_record_types_tests", moduleName = "parse_string_record_types_tests"}
+]
+
+[[package]]
+org = "ballerina"
+name = "test"
+version = "0.0.0"
+scope = "testOnly"
+dependencies = [
+ {org = "ballerina", name = "jballerina.java"},
+ {org = "ballerina", name = "lang.array"},
+ {org = "ballerina", name = "lang.error"}
+]
+modules = [
+ {org = "ballerina", packageName = "test", moduleName = "test"}
+]
+
diff --git a/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_map_tests.bal b/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_map_tests.bal
new file mode 100644
index 0000000..7a831e9
--- /dev/null
+++ b/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_map_tests.bal
@@ -0,0 +1,425 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// 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;
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndMapAsExpectedType() {
+ BooleanMapArray|csv:Error bv1bma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ BooleanMapArray|csv:Error bv2bma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ BooleanMapArray|csv:Error bv3bma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ BooleanMapArray|csv:Error bv4bma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bma, [
+ {b1: true, b4: false},
+ {b1: true, b4: false}
+ ]);
+
+ BooleanMapArray|csv:Error bv5bma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: true}
+ ]);
+
+ BooleanMapArray|csv:Error bv6bma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bma, [
+ {}
+ ]);
+
+ BooleanMapArray|csv:Error bv7bma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bma, [
+ {b1, b2, b4}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv1bnbma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bnbma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv2bnbma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bnbma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv3bnbma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bnbma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: null},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv4bnbma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bnbma, [
+ {b1: true, b2: (), b3: (), b4: false},
+ {b1: true, b2: (), b3: (), b4: false}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv5bnbma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bnbma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: true}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv6bnbma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bnbma, [
+ {b2: (), b3: ()}
+ ]);
+
+ NillableBooleanMapArray|csv:Error bv7bnbma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bnbma, [
+ {b1, b2, b3, b4}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv1bniubma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bniubma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv2bniubma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bniubma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndMapAsExpectedType2() {
+ NillableIntUnionBooleanMapArray|csv:Error bv3bniubma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bniubma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: null},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv4bniubma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bniubma, [
+ {b1: true, b2: (), b3: (), b4: false},
+ {b1: true, b2: (), b3: (), b4: false}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv5bniubma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bniubma, [
+ {b1: true, b2: false, b3: true, b4: 2},
+ {b1: true, b2: false, b3: true, b4: 3}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv6bniubma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bniubma, [
+ {b2: (), b3: ()}
+ ]);
+
+ NillableIntUnionBooleanMapArray|csv:Error bv7bniubma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bniubma, [
+ {b1, b2, b3, b4}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv1biubma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1biubma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv2biubma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2biubma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv3biubma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3biubma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv4biubma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4biubma, [
+ {b1: true, b4: false},
+ {b1: true, b4: false}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv5biubma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5biubma, [
+ {b1: true, b2: false, b3: true, b4: 2},
+ {b1: true, b2: false, b3: true, b4: 3}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv6biubma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6biubma, [
+ {}
+ ]);
+
+ IntUnionBooleanMapArray|csv:Error bv7biubma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7biubma, [
+ {b1, b2, b4}
+ ]);
+
+ NilMapArray|csv:Error bv1bnma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bnma, [
+ {},
+ {},
+ {}
+ ]);
+
+ NilMapArray|csv:Error bv2bnma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bnma, [
+ {},
+ {}
+ ]);
+
+ NilMapArray|csv:Error bv3bnma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bnma, [
+ {},
+ {b3: ()},
+ {}
+ ]);
+
+ NilMapArray|csv:Error bv4bnma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bnma, [
+ {b2: (), b3: ()},
+ {b2: (), b3: ()}
+ ]);
+
+ NilMapArray|csv:Error bv5bnma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bnma, [
+ {},
+ {}
+ ]);
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndMapAsExpectedType3() {
+ NilMapArray|csv:Error bv6bnma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bnma, [
+ {b2: (), b3: ()}
+ ]);
+
+ NilMapArray|csv:Error bv7bnma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bnma, [
+ {b3}
+ ]);
+
+ JsonMapArray|csv:Error bv1bjma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bjma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ JsonMapArray|csv:Error bv2bjma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bjma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ JsonMapArray|csv:Error bv3bjma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bjma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: null},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ JsonMapArray|csv:Error bv4bjma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bjma, [
+ {b1: true, b2: (), b3: (), b4: false},
+ {b1: true, b2: (), b3: (), b4: false}
+ ]);
+
+ JsonMapArray|csv:Error bv5bjma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bjma, [
+ {b1: true, b2: false, b3: true, b4: 2},
+ {b1: true, b2: false, b3: true, b4: 3}
+ ]);
+
+ JsonMapArray|csv:Error bv6bjma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bjma, [
+ {b2: (), b3: ()}
+ ]);
+
+ JsonMapArray|csv:Error bv7bjma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bjma, [
+ {b1, b2, b3, b4}
+ ]);
+
+ AnydataMapArray|csv:Error bv1banydma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1banydma, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ AnydataMapArray|csv:Error bv2banydma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2banydma, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ AnydataMapArray|csv:Error bv3banydma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3banydma, [
+ {b1: true, b2: false, b3: true},
+ {b1: true, b2: false, b3: null},
+ {b1: true, b2: true, b3: false}
+ ]);
+
+ AnydataMapArray|csv:Error bv4banydma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4banydma, [
+ {b1: true, b2: (), b3: (), b4: false},
+ {b1: true, b2: (), b3: (), b4: false}
+ ]);
+
+ AnydataMapArray|csv:Error bv5banydma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5banydma, [
+ {b1: true, b2: false, b3: true, b4: 2},
+ {b1: true, b2: false, b3: true, b4: 3}
+ ]);
+
+ AnydataMapArray|csv:Error bv6banydma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6banydma, [
+ {b2: (), b3: ()}
+ ]);
+
+ AnydataMapArray|csv:Error bv7banydma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7banydma, [
+ {b1, b2, b3, b4}
+ ]);
+
+ CustomMapArray|csv:Error bv1bcma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bcma, [
+ {b1: "true", b2: "false", b3: "true", b4: "false"},
+ {b1: "true", b2: "false", b3: "true", b4: "false"},
+ {b1: "true", b2: "false", b3: "true", b4: "false"}
+ ]);
+}
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndMapAsExpectedType4() {
+ CustomMapArray|csv:Error bv2bcma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bcma, [
+ {b1: "true", b2: "false", b3: "true", b4: "false", b5: "true"},
+ {b1: "true", b2: "false", b3: "true", b4: "false", b5: "true"}
+ ]);
+
+ CustomMapArray|csv:Error bv3bcma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bcma, [
+ {b1: "true", b2: "false", b3: "true"},
+ {b1: "TRUE", b2: "FALSE", b3: "()"},
+ {b1: "true", b2: "true", b3: "FALSE"}
+ ]);
+
+ CustomMapArray|csv:Error bv4bcma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bcma, [
+ {b1: "true", b2: "()", b3: "()", b4: "false"},
+ {b1: "true", b2: "()", b3: "null", b4: "false"}
+ ]);
+
+ CustomMapArray|csv:Error bv5bcma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bcma, [
+ {b1: "true", b2: "false", b3: "true", b4: 2},
+ {b1: "true", b2: "false", b3: "true", b4: 3}
+ ]);
+
+ CustomMapArray|csv:Error bv6bcma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bcma, [
+ {b2: "()", b3: "()"}
+ ]);
+
+ CustomMapArray|csv:Error bv7bcma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bcma, [
+ {b1: "true", b2: "false", b3: "()", b4: "false"}
+ ]);
+
+ StringMapArray|csv:Error bv1bsma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1bsma, [
+ {b1: "true", b2: "false", b3: "true", b4: "false"},
+ {b1: "true", b2: "false", b3: "true", b4: "false"},
+ {b1: "true", b2: "false", b3: "true", b4: "false"}
+ ]);
+
+ StringMapArray|csv:Error bv2bsma = csv:parseString(csvStringWithBooleanValues2);
+ test:assertEquals(bv2bsma, [
+ {b1: "true", b2: "false", b3: "true", b4: "false", b5: "true"},
+ {b1: "true", b2: "false", b3: "true", b4: "false", b5: "true"}
+ ]);
+
+ StringMapArray|csv:Error bv3bsma = csv:parseString(csvStringWithBooleanValues3);
+ test:assertEquals(bv3bsma, [
+ {b1: "true", b2: "false", b3: "true"},
+ {b1: "TRUE", b2: "FALSE", b3: "()"},
+ {b1: "true", b2: "true", b3: "FALSE"}
+ ]);
+
+ StringMapArray|csv:Error bv4bsma = csv:parseString(csvStringWithBooleanValues4);
+ test:assertEquals(bv4bsma, [
+ {b1: "true", b2: "()", b3: "()", b4: "false"},
+ {b1: "true", b2: "()", b3: "null", b4: "false"}
+ ]);
+
+ StringMapArray|csv:Error bv5bsma = csv:parseString(csvStringWithBooleanValues5);
+ test:assertEquals(bv5bsma, [
+ {b1: "true", b2: "false", b3: "true", b4: "2"},
+ {b1: "true", b2: "false", b3: "true", b4: "3"}
+ ]);
+
+ StringMapArray|csv:Error bv6bsma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6bsma, [
+ {b2: "()", b3: "()"}
+ ]);
+
+ StringMapArray|csv:Error bv7bsma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7bsma, [
+ {b1: "true", b2: "false", b3: "()", b4: "false"}
+ ]);
+
+ DecimalMapArray|csv:Error bv1dsma = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(bv1dsma, [
+ {},
+ {},
+ {}
+ ]);
+ DecimalMapArray|csv:Error bv6dsma = csv:parseString(csvStringWithBooleanValues6);
+ test:assertEquals(bv6dsma, [
+ {}
+ ]);
+
+ DecimalMapArray|csv:Error bv7dsma = csv:parseString(csvStringWithBooleanValues7);
+ test:assertEquals(bv7dsma, [
+ {}
+ ]);
+}
diff --git a/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_record_tests.bal b/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_record_tests.bal
new file mode 100644
index 0000000..1a6b01a
--- /dev/null
+++ b/ballerina-tests/parse-string-record-types-tests/tests/parse_string_to_record_tests.bal
@@ -0,0 +1,519 @@
+// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+//
+// WSO2 LLC. licenses this file to you under the Apache License,
+// Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import ballerina/csv_commons as common;
+import ballerina/data.csv;
+import ballerina/test;
+
+@test:Config
+function testFromCsvStringWithTypeForStringAndRecordAsExpectedType() {
+ BooleanRecord1Array|csv:Error csvb1br1 = csv:parseString(csvStringWithBooleanValues1);
+ test:assertEquals(csvb1br1, [
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false},
+ {b1: true, b2: false, b3: true, b4: false}
+ ]);
+
+ BooleanRecord1Array|csv:Error csvb2br1 = csv:parseString(csvStringWithBooleanValues2, {});
+ test:assertEquals(csvb2br1, [
+ {b1: true, b2: false, b3: true, b4: false, b5: true},
+ {b1: true, b2: false, b3: true, b4: false, b5: true}
+ ]);
+
+ BooleanRecord1Array|csv:Error csvb3br1 = csv:parseString(csvStringWithBooleanValues3, {});
+ test:assertTrue(csvb3br1 is csv:Error);
+ test:assertEquals((csvb3br1).message(), common:generateErrorMessageForMissingRequiredField("b4"));
+
+ BooleanRecord1Array|csv:Error csvb4br1 = csv:parseString(csvStringWithBooleanValues4, {});
+ test:assertEquals(csvb4br1, [
+ {b1: true, b2: "()", b3: (), b4: false},
+ {b1: true, b2: "()", b3: (), b4: false}
+ ]);
+
+ BooleanRecord1Array|csv:Error csvb5br1 = csv:parseString(csvStringWithBooleanValues5, {});
+ test:assertTrue(csvb5br1 is csv:Error);
+ test:assertEquals((csvb5br1).message(), common:generateErrorMessageForInvalidCast("2", "boolean"));
+
+ BooleanRecord1Array|csv:Error csvb6br1 = csv:parseString(csvStringWithBooleanValues6, {});
+ test:assertTrue(csvb6br1 is csv:Error);
+ test:assertEquals((