blob: 35f018db7b828cfb65fec580d324174f7430d678 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/**
* Copyright (c) 2011-2012 Eclipse contributors and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*/
package org.eclipse.emf.test.ecore.xcore.interpreter;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.xcore.XPackage;
import org.eclipse.emf.test.ecore.xcore.XcoreStandaloneInjectorProvider;
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.eclipse.xtext.xbase.testing.evaluation.AbstractXbaseEvaluationTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.google.inject.Inject;
@RunWith(XtextRunner.class)
@InjectWith(XcoreStandaloneInjectorProvider.class)
public class XcoreInterpreterXbaseIntegrationTest extends AbstractXbaseEvaluationTest
{
@Inject
private ParseHelper<XPackage> parser;
@Inject
private ValidationTestHelper validator;
@Override
protected Object invokeXbaseExpression(String expression) throws Exception
{
XPackage pack = parser.parse("package foo type Exception wraps Exception class Bar { op Object foo() throws Exception { " + expression + " } }");
validator.assertNoErrors(pack);
EPackage ePack = (EPackage)pack.eResource().getContents().get(2);
EClass barClass = (EClass)ePack.getEClassifier("Bar");
EObject eObject = ePack.getEFactoryInstance().create(barClass);
return eObject.eInvoke(barClass.getEOperations().get(0), new BasicEList<Object>());
}
@Override
@Test public void testSwitchExpressionOverEnum_6() throws Exception {
assertEvaluatesTo(null,
"{\n" +
" val Enum<?> e = null\n" +
" switch(e) {\n" +
" java.lang.^annotation.RetentionPolicy: e.toString\n" +
" java.lang.^annotation.ElementType: e.toString\n" +
" }\n" +
"}");
}
@Override
@Test
public void testReservedWordEnum() throws Exception
{
assertEvaluatesTo(Boolean.TRUE, "typeof(java.lang.^annotation.RetentionPolicy).enum");
}
@Override
@Test
public void testSwitchExpression_27() throws Exception {
// annotation is a reserved word in Xcore
assertEvaluatesTo(Boolean.FALSE,
"{ val Object policy = java.lang.^annotation.RetentionPolicy.SOURCE switch policy { java.lang.^annotation.RetentionPolicy case CLASS: false } }");
}
@Override
@Test
public void testArrays_01() throws Exception
{
try
{
super.testArrays_01();
fail("Expecting an exception; it must be working now.");
}
catch (Exception exception)
{
// Expecting it to fail right now.
}
}
@Override
@Test
public void testArrays_02() throws Exception
{
try
{
super.testArrays_02();
fail("Expecting an exception; it must be working now.");
}
catch (Exception exception)
{
// Expecting it to fail right now.
}
}
@Override
@Test
public void testArrays_04() throws Exception
{
try
{
super.testArrays_04();
fail("Expecting an exception; it must be working now.");
}
catch (Exception exception)
{
// Expecting it to fail right now.
}
}
@Override
@Test
public void testClosure_31() throws Exception
{
try
{
super.testClosure_31();
fail("Expecting an exception; it must be working now.");
}
catch (Exception exception)
{
// Expecting it to fail right now.
}
}
@Override
public void testClosure_32() throws Exception
{
try
{
super.testClosure_32();
fail("Expecting an exception; it must be working now.");
}
catch (Exception exception)
{
// Expecting it to fail right now.
}
}
}
|