Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 502e067ea8150dd9f1d58efd69073ded92ad5c9a (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
/*
 * generated by Xtext 2.10.0-SNAPSHOT
 */
package org.eclipse.qvtd.doc.minioclcs.xtext.tests

import com.google.inject.Inject
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.util.ParseHelper
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.eclipse.qvtd.doc.minioclcs.RootCS
import junit.framework.TestCase

@RunWith(XtextRunner)
@InjectWith(MiniOCLCSInjectorProvider)
class MiniOCLCSParsingTest extends TestCase {

	@Inject
	ParseHelper<RootCS> parseHelper

	@Test 
	def void testSimpleMiniOCL_PackagesDef() {
		val result = parseHelper.parse('''
			package ocl {
				
				class String {}
			}
			
			package package1 {
				
				class c1 {		
					prop a : ocl::String;
					op getA() : ocl::String = a;
				}
			}

		''')
		Assert.assertNotNull(result)
	}

	@Test 
	def void testSimpleMiniOCL_Invariant() {
		val result = parseHelper.parse('''
			package package1 {
				
				class c1 {
					
					prop a : String;
					
					op giveMeA() : String = self.c1;
					
					op testA() : Boolean = giveMeA().size() <> 0; 
				}
			}
			
			context package1::c1 {
				inv : a = giveMeA();
				inv : testA();
			}
		''')
		Assert.assertNotNull(result)
	}

}

Back to the top