8000 Feature/xtext acme by schmerl · Pull Request #92 · cmu-able/rainbow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/xtext acme #92

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions documents/RCL.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ model factory SWIM yields org.sa.rainbow.^model.^acme.swim.commands.SwimCommandF
for org.sa.rainbow.^model.^acme.AcmeModelInstance

command load is org.sa.rainbow.^model.^acme.swim.commands.SwimLoadModelCommand
command setDimmer(acme::SwimFam.LoadBalancerT target, int dimmer)
command setDimmer(SwimFam.LoadBalancerT target, int dimmer)
is org.sa.rainbow.^model.^acme.swim.commands.SetDimmerCmd;
...
}
Expand All @@ -401,16 +401,16 @@ It is also possible to specify an operation to save a model when Rainbow is fini
After this comes the list of operations that the model can produce, e.g.:

```
command setDimmer(acme::SwimFam.LoadBalancerT target, int dimmer)
command setDimmer(SwimFam.LoadBalancerT target, int dimmer)
is org.sa.rainbow.^model.^acme.swim.commands.SetDimmerCmd;
```

The first part is the name of the operation (which may be referred to by gauges and
effectors), e.g., _setDimmer_. Following this are the parameters for the operation.
The first argument may be a **target** which specifies the kind of model element that
the operation is defined on. The following list of arguments specify the operation paramters.
Operation argument types can refer to Acme types (by prefixing the type name with **acme::*,
Java types, or builtin types like **int**, **String**, etc.). Finally, the operation
Operation argument types can refer to Acme types,
Java types, or builtin types like **int**, **String**, etc. Finally, the operation
specifies the implementing class for the operation.

## Probe Specifications
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.acme.xtext.tests
Bundle-ManifestVersion: 2
Bundle-Name: org.acme.xtext.tests
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: org.acme.xtext.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.acme.xtext;bundle-version="1.0.0",
org.junit.jupiter.api;bundle-version="[5.0.0,6.0.0)",
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/,\
src-gen/,\
xtend-gen/
bin.includes = .,\
META-INF/
bin.excludes = **/*.xtend
21 changes: 21 additions & 0 deletions ide/org.acme.xtext.parent/org.acme.xtext.tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.acme.xtext</groupId>
<artifactId>org.acme.xtext.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.acme.xtext.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
package org.acme.xtext.tests

import com.google.inject.Inject
import org.acme.acme.AcmeCompUnit
import org.acme.acme.AcmePackage
import org.acme.validation.Diagnostics
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.util.ParseHelper
import org.eclipse.xtext.testing.validation.ValidationTestHelper
import org.junit.Test
import org.junit.runner.RunWith

import static org.junit.Assert.assertNotNull

@RunWith(XtextRunner)
@InjectWith(AcmeInjectorProvider)
class AcmeCompoundPropertyTest {
@Inject extension ParseHelper<AcmeCompUnit> parserHelper

@Inject extension ValidationTestHelper

@Test
def void testSetWrongType() {
'''
system s = {
property prop : set{string} = {"hello", 1};
}
'''.parse => [
assertNotNull(it)
assertError(AcmePackage::eINSTANCE.acmePropertyDeclaration, Diagnostics.TYPES_INCOMPATIBLE)
]
}

@Test
def void testSetOK() {
'''
system s = {
property prop : set{string} = {"hello", "there"};
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void testSetOfSetWrongType() {
'''
system s = {
property prop : set{set{double}} = {{"hello", 1}, {1.2, 3.4, 5.6, 7.8}};
}
'''.parse => [
assertNotNull(it)
assertError(AcmePackage::eINSTANCE.acmePropertyDeclaration, Diagnostics.TYPES_INCOMPATIBLE)
]
}

@Test
def void testSetOfSetOK() {
'''
system s = {
property prop : set{set{double}} = {{1,2,3}, {1.2, 3.4, 5.6, 7.8}};
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void testSeqWrongType() {
'''
system s = {
property prop : seq<string> = <"hello", 1>;
}
'''.parse => [
assertNotNull(it)
assertError(AcmePackage::eINSTANCE.acmePropertyDeclaration, Diagnostics.TYPES_INCOMPATIBLE)
]
}

@Test
def void testSeqOK() {
'''
system s = {
property prop : seq<string> = <"hello", "there">;
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void testRecordSameOrderOK() {
'''
system s = {
property prop : record[field1 : int; field2 : string;] = [field1=1; field2="hello";];
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void testRecordDifferentOrderOK() {
'''
system s = {
property prop : record[field1 : int; field2 : string;] = [field2="hello";field1=1;];
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void testRecordDifferentOrderFailType() {
'''
system s = {
property prop : record[field1 : int; field2 : string;] = [field2="hello";field1=1.2;];
}
'''.parse => [
assertNotNull(it)
assertError(AcmePackage::eINSTANCE.acmePropertyDeclaration, Diagnostics.TYPES_INCOMPATIBLE)
]
}

@Test
def void testRecordDifferentOrderSubFeldTypeOK() {
'''
system s = {
property prop : record[field1 : float; field2 : string;] = [field2="hello";field1=1;];
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void textRecordInRecordDifferentOrderSubFieldTypeOK() {
'''
system s = {
property prop : record[
a:record[a : float;
b : string;
];
b: any;] =
[a = [a = 1; b = "me";]; b = false;];
}
'''.parse => [
assertNotNull(it)
assertNoErrors
]
}

@Test
def void textRecordInRecordDifferentOrderSubFieldTypeFail() {
'''
system s = {
property prop : record[
a:record[a : float;
b : string;
];
b: any;] =
[a = [a = 1; b = false;]; b = false;];
}
'''.parse => [
assertNotNull(it)
assertError(AcmePackage::eINSTANCE.acmePropertyDeclaration, Diagnostics.TYPES_INCOMPATIBLE)
]
}
}
Loading
0