package net.xprova.xprova;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;

import org.junit.Test;

import net.xprova.propertylanguage.Property;

public class PropertyParserTest {

	@Test
	public void testUnaryOperators() throws Exception {

		String[] ops = { "~" };

		for (String s : ops) {

			Property p = new Property(String.format("%sx", s));

			ArrayList<String> ids = p.getIdentifiers();

			assertEquals(ids.size(), 1);

			assertEquals(ids.get(0), "x");

		}
	}

	@Test
	public void testBinaryOperators() throws Exception {

		String[] ops = { "&", "|", "^", "==", "!=", "|->", "|=>" };

		for (String s : ops) {

			Property p = new Property(String.format("x %s y", s));

			ArrayList<String> ids = p.getIdentifiers();

			assertEquals(ids.size(), 2);

			assertEquals(ids.get(0), "x");

			assertEquals(ids.get(1), "y");
		}

	}

	@Test
	public void testFunctions() throws Exception {

		String[] ops = { "$rose", "$fell", "$fell", "$changed" };

		for (String s : ops) {

			Property p = new Property(String.format("%s (x)", s));

			ArrayList<String> ids = p.getIdentifiers();

			assertEquals(ids.size(), 2);

			assertEquals(ids.get(0), "x");

		}

	}

	@Test
	public void testDelayOperators() throws Exception {

		String[] ops = { "@1", "#1" };

		for (String s : ops) {

			Property p = new Property(String.format("%s x", s));

			ArrayList<String> ids = p.getIdentifiers();

			assertEquals(ids.size(), 1);

			assertEquals(ids.get(0), "x");

		}

	}

}

@@ -25,83 +25,8 @@
 a;%0A%0A
-import static org.junit.Assert.assertEquals;%0A%0Aimport java.util.ArrayList;%0A%0A
 impo
@@ -239,37 +239,24 @@
  ops) %7B%0A%0A%09%09%09
-Property p = 
 new Property
@@ -287,124 +287,8 @@
 );%0A%0A
-%09%09%09ArrayList%3CString%3E ids = p.getIdentifiers();%0A%0A%09%09%09assertEquals(ids.size(), 1);%0A%0A%09%09%09assertEquals(ids.get(0), %22x%22);%0A%0A
 %09%09%7D%0A
@@ -441,37 +441,24 @@
  ops) %7B%0A%0A%09%09%09
-Property p = 
 new Property
@@ -492,158 +492,8 @@
 );%0A%0A
-%09%09%09ArrayList%3CString%3E ids = p.getIdentifiers();%0A%0A%09%09%09assertEquals(ids.size(), 2);%0A%0A%09%09%09assertEquals(ids.get(0), %22x%22);%0A%0A%09%09%09assertEquals(ids.get(1), %22y%22);%0A
 %09%09%7D%0A
@@ -588,28 +588,30 @@
  %22$fell%22, %22$
-fell
+stable
 %22, %22$changed
@@ -641,37 +641,24 @@
  ops) %7B%0A%0A%09%09%09
-Property p = 
 new Property
@@ -692,124 +692,8 @@
 );%0A%0A
-%09%09%09ArrayList%3CString%3E ids = p.getIdentifiers();%0A%0A%09%09%09assertEquals(ids.size(), 2);%0A%0A%09%09%09assertEquals(ids.get(0), %22x%22);%0A%0A
 %09%09%7D%0A
@@ -825,21 +825,8 @@
 %0A%09%09%09
-Property p = 
 new 
@@ -866,124 +866,8 @@
 );%0A%0A
-%09%09%09ArrayList%3CString%3E ids = p.getIdentifiers();%0A%0A%09%09%09assertEquals(ids.size(), 1);%0A%0A%09%09%09assertEquals(ids.get(0), %22x%22);%0A%0A
 %09%09%7D%0A

Fix PropertyParserTest