module examples::pascal::Test
rascal-0.40.16
typepal-0.14.8
Usage
import examples::pascal::Test;
Source code
http://github.com/usethesource/typepal/src/examples/pascal/Test.rsc
Dependencies
import examples::pascal::Syntax;
extend examples::pascal::Checker;
extend analysis::typepal::TestFramework;
import ParseTree;
import IO;
import util::Reflective;
function pascalTModelForTree
TModel pascalTModelForTree(Tree pt, str programName, PathConfig _, bool _){
if(pt has top) pt = pt.top;
c = newCollector(programName, pt, pascalConfig());
pascalPreCollectInitialization(pt, c);
collect(pt, c);
return newSolver(pt, c.run()).run();
}
TModel pascalTModelForTree(Tree pt, bool _){
if(pt has top) pt = pt.top;
c = newCollector("pascal", pt, pascalConfig());
pascalPreCollectInitialization(pt, c);
collect(pt, c);
return newSolver(pt, c.run()).run();
}
function pascalTModelForName
TModel pascalTModelForName(str mname, bool debug){
pt = parse(#start[Program], |project://typepal/src/examples/pascal/examples/<mname>.pascal|).top;
return pascalTModelForTree(pt, debug);
}
function main
value main()
= pascalTests();
Tests
test pascalTests
test bool pascalTests() {
//println("**** PASCALTESTS DISABLED ****");
//return true;
bool ok = runTests([|project://typepal/src/examples/pascal/expression-tests.ttl|,
|project://typepal/src/examples/pascal/statement-tests.ttl|
], #start[Program], TModel (Tree t) { return pascalTModelForTree(t, false); },
runName = "Pascal");
println("Executing Pascal examples\r");
int n = 0;
for(ex <- examples){
n += 1;
msgs = pascalTModelForName(ex, false).messages;
if(isEmpty(msgs)){
print("<spinChar(n)> <ex>: ok\r");
} else {
println("<ex>:");
println(msgs);
ok = false;
}
}
println("Executing Pascal examples: <ok>");
return ok;
}