Skip to content

Commit

Permalink
fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
housengw committed Jan 24, 2022
1 parent 16437f8 commit d132bfe
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 36 deletions.
51 changes: 51 additions & 0 deletions conv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
s = '''
target C;
reactor X {
reaction() {=
//
=}
p = new Y();
}
reactor Y {
q = new X();
}
'''

import os
os.system('clear')

def printTestCase():
global s
s = s.replace('"', '\\"')
lines = s.split("\n")[1:-1]

l = [f' "{line}"' + ',' if i != len(lines) - 1 else f' "{line}"' for i, line in enumerate(lines)]

testcase = 'String testCase = String.join(System.getProperty("line.separator"),\n'

for i, v in enumerate(l):
testcase += v
if i != len(l) - 1:
testcase += '\n'

testcase += '\n);'

print(testcase)

def printJavaString():
lines = s.split("\n")[1:-1]

l = ['// ' + 12 * ' ' + line + '\n' if i != len(lines) - 1 else '// ' + 12 * ' ' + line for i, line in enumerate(lines)]

js = f'''
// Java 17:
// String testCase = """
{''.join(l)}
// """
// Java 11:'''
print(js)

printJavaString()
printTestCase()
22 changes: 12 additions & 10 deletions org.lflang.tests/.classpath
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" output="test-bin" path="src">
<classpathentry kind="src" output="bin/test" path="src">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="test-bin" path="xtend-gen">
<classpathentry kind="src" output="bin/test" path="xtend-gen">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="test-bin" path="src-gen">
<classpathentry kind="src" output="bin/test" path="src-gen">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
19 changes: 18 additions & 1 deletion org.lflang.tests/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
Expand All @@ -30,5 +35,17 @@
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1642882128693</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,15 @@ public void detectCausalityLoop() throws Exception {
"target C;",
"",
"reactor X {",
" input x:int",
" input x:int;",
" output y:int;",
" reaction(x) -> y {=",
" =}",
"}",
"",
"main reactor {",
" a = new X()",
" a = new X()",
" b = new X()",
" a.y -> b.x",
" b.y -> a.x",
"}"
Expand Down Expand Up @@ -880,7 +880,7 @@ public void nonZeroTimeValueWithoutUnits() throws Exception {
// main reactor {
// timer t(42, 1 sec);
// reaction(t) {=
// printf("Hello World.\n");
// printf("Hello World.\\n");
// =}
// }
// """
Expand All @@ -890,7 +890,7 @@ public void nonZeroTimeValueWithoutUnits() throws Exception {
"main reactor {",
" timer t(42, 1 sec);",
" reaction(t) {=",
" printf(\"Hello World.\n\");",
" printf(\"Hello World.\\n\");",
" =}",
"}");
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getValue(), null, "Missing time unit.");
Expand All @@ -907,7 +907,7 @@ public void parameterTypeMismatch() throws Exception {
// main reactor (p:int(0)) {
// timer t(p, 1 sec);
// reaction(t) {=
// printf("Hello World.\n");
// printf("Hello World.\\n");
// =}
// }
// """
Expand All @@ -917,7 +917,7 @@ public void parameterTypeMismatch() throws Exception {
"main reactor (p:int(0)) {",
" timer t(p, 1 sec);",
" reaction(t) {=",
" printf(\"Hello World.\n\");",
" printf(\"Hello World.\\n\");",
" =}",
"}");
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getValue(),
Expand All @@ -935,7 +935,7 @@ public void targetCodeInTimeArgument() throws Exception {
// main reactor {
// timer t({=foo()=}, 1 sec);
// reaction(t) {=
// printf("Hello World.\n");
// printf("Hello World.\\n");
// =}
// }
// """
Expand All @@ -945,7 +945,7 @@ public void targetCodeInTimeArgument() throws Exception {
"main reactor {",
" timer t({=foo()=}, 1 sec);",
" reaction(t) {=",
" printf(\"Hello World.\n\");",
" printf(\"Hello World.\\n\");",
" =}",
"}");
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getValue(),
Expand All @@ -964,7 +964,7 @@ public void overflowingDeadlineC() throws Exception {
// main reactor {
// timer t;
// reaction(t) {=
// printf("Hello World.\n");
// printf("Hello World.\\n");
// =} deadline (40 hours) {=
// =}
// }
Expand All @@ -975,7 +975,7 @@ public void overflowingDeadlineC() throws Exception {
"main reactor {",
"timer t;",
" reaction(t) {=",
" printf(\"Hello World.\n\");",
" printf(\"Hello World.\\n\");",
" =} deadline (40 hours) {=",
" =}",
"}");
Expand All @@ -996,8 +996,7 @@ public void overflowingParameterC() throws Exception {
// main reactor(d:time(40 hours)) {
// timer t;
// reaction(t) {=
// printf("Hello World.
// ");
// printf("Hello World.\\n");
// =} deadline (d) {=
// =}
// }
Expand All @@ -1008,8 +1007,7 @@ public void overflowingParameterC() throws Exception {
"main reactor(d:time(40 hours)) {",
"timer t;",
" reaction(t) {=",
" printf(\"Hello World.",
"\");",
" printf(\"Hello World.\\n\");",
" =} deadline (d) {=",
" =}",
"}");
Expand All @@ -1030,7 +1028,7 @@ public void overflowingAssignmentC() throws Exception {
// reactor Print(d:time(39 hours)) {
// timer t;
// reaction(t) {=
// printf("Hello World.\n");
// printf("Hello World.\\n");
// =} deadline (d) {=
// =}
// }
Expand All @@ -1044,7 +1042,7 @@ public void overflowingAssignmentC() throws Exception {
"reactor Print(d:time(39 hours)) {",
" timer t;",
" reaction(t) {=",
" printf(\"Hello World.\n\");",
" printf(\"Hello World.\\n\");",
" =} deadline (d) {=",
" =}",
"}",
Expand Down Expand Up @@ -1333,7 +1331,7 @@ public void recognizeIPV6() throws Exception {
String.join(System.getProperty("line.separator"),
"target C;",
"reactor Y {}",
String.format("federated reactor X at [foo@%s]:4242 {", addr),
String.format("federated reactor at [foo@%s]:4242 {", addr),
String.format(" y = new Y() at [%s]:2424; ", addr),
"}")
);
Expand Down
25 changes: 18 additions & 7 deletions org.lflang/.classpath
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="src" output="bin/main" path="src">
<attributes>
<attribute name="module" value="true"/>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" output="bin/main" path="src-gen">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="xtend-gen">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
8 changes: 7 additions & 1 deletion org.lflang/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
Expand All @@ -30,6 +35,7 @@
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
Expand Down

0 comments on commit d132bfe

Please sign in to comment.