Skip to content

Commit

Permalink
Handle U type tests
Browse files Browse the repository at this point in the history
Fix an incorrect test case.
Fixes #81
  • Loading branch information
jclark committed Jun 20, 2021
1 parent 0ac7b55 commit 6a9bf83
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
public function main() {
io:println(0); // @error
}

5 changes: 0 additions & 5 deletions compiler/testSuite/Elib00.bal

This file was deleted.

6 changes: 6 additions & 0 deletions compiler/testSuite/Ulib00.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ballerina/io;

public function main() {
io:print(4); // @output 41
io:println(1);
}
17 changes: 12 additions & 5 deletions compiler/tests/testSuite.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,27 @@ function testCompileVP(string path) returns io:Error? {
}

@test:Config {
dataProvider: listSourcesE
dataProvider: listSourcesEU
}
function testCompileE(string path) returns io:Error? {
function testCompileEU(string path) returns file:Error|io:Error? {
CompileError? err = compileFile(path, ());
// JBUG parentheses needed
if (err is err:Any?) {
if err is () {
test:assertNotExactEquals(err, (), "expected an error " + path);
}
else {
// XXX distinguish E and U tests
string base = check file:basename(path);
boolean isE = base[0].toUpperAscii() == "E";
if isE {
test:assertFalse(err is err:Unimplemented, "unimplemented error on E test" + path);
}
else {
test:assertFalse(err is err:Semantic, "semantic error on U test" + path);
}
// JBUG cast needed
err:Position? pos = (<err:Detail>err.detail())?.position;
if pos != () {
if isE && pos != () {
test:assertEquals(pos.lineNumber, check errorLine(path), "wrong line number in error " + path);
}
}
Expand All @@ -54,7 +61,7 @@ function testCompileE(string path) returns io:Error? {

function listSourcesVP() returns string[][]|error => listSources("VP");

function listSourcesE() returns string[][]|error => listSources("E");
function listSourcesEU() returns string[][]|error => listSources("EU");

function listSources(string initialChars) returns string[][]|io:Error|file:Error {
return from var entry in check file:readDir(SOURCE_DIR)
Expand Down

0 comments on commit 6a9bf83

Please sign in to comment.