Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression tests #112

Merged
merged 24 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.eclipse.xtext.validation.Issue.IssueImpl
import static org.junit.jupiter.api.Assertions.*

import static extension com.minres.coredsl.util.ModelExtensions.*
import com.minres.coredsl.coreDsl.Expression
import com.minres.coredsl.analysis.CoreDslConstantExpressionEvaluator

class CoreDslTestCase<TRoot> {
final static Pattern newLinePattern = Pattern.compile("\r?\n");
Expand All @@ -36,6 +38,7 @@ class CoreDslTestCase<TRoot> {
final List<IssueDescription> expectedIssues = new ArrayList();
final List<Expectation> semanticExpectations = new ArrayList();

boolean forceEvaluateExpressions;
boolean checkDiagnosticsOnly;
boolean isGenericSyntaxTest;
boolean hasRun;
Expand All @@ -59,6 +62,11 @@ class CoreDslTestCase<TRoot> {
}
this.prologLines = prologLines;
}

def evaluateExpressions() {
forceEvaluateExpressions = true;
return this;
}

def diagnosticsOnly() {
checkDiagnosticsOnly = true;
Expand Down Expand Up @@ -237,6 +245,16 @@ class CoreDslTestCase<TRoot> {
if(!checkDiagnosticsOnly) {
val sink = new ValidationMessageSink();
results = CoreDslAnalyzer.analyze(model, sink);

if(forceEvaluateExpressions) {
for(isa : results.results.keySet) {
val ctx = results.results.get(isa);
for(expr : isa.descendantsOfType(Expression)) {
CoreDslConstantExpressionEvaluator.evaluate(ctx, expr);
}
}
}

issues.addAll(sink.issues);
}

Expand Down
Loading
Loading