Package urban.parser

Source Code of urban.parser.UrbanParserTest

package urban.parser;

import static org.junit.Assert.*;

import org.antlr.runtime.RecognitionException;
import org.junit.Test;

import urban.model.AbstractStatement;
import urban.model.Initialisation;
import urban.model.Modification;
import urban.model.Rule;
import urban.model.Story;
import urban.model.Variable;

public class UrbanParserTest {
  @Test
  public void testInitialise() throws RecognitionException {
    String expected = "%init: 5 * A(),B()\n";
    UrbanParser parser = new UrbanParser(expected);
    Initialisation init = (Initialisation) parser.line();
    assertEquals(expected, init.toString())
  }

  @Test
  public void testRule() throws RecognitionException {
    String expected = "A() -> B() @ 1\n";
    UrbanParser parser = new UrbanParser(expected);
    Rule rule = (Rule) parser.line();
    assertEquals(expected, rule.toString());
  }

  @Test
  public void testObserve() throws RecognitionException {
    String expected = "%obs: 'a-b' A(a~s?),B()\n";
    UrbanParser parser = new UrbanParser(expected);
    AbstractStatement line = (AbstractStatement) parser.line();
    assertEquals(expected, line.toString())
  }

  @Test
  public void testVariable()  throws RecognitionException {
    String expected = "%var: \"foo\" A(),B()\n";
    UrbanParser parser = new UrbanParser(expected);
    Variable line = (Variable) parser.line();
    assertEquals(expected, line.toString())
  }

  @Test
  public void testStory()  throws RecognitionException {
    String expected = "%causal: \"foo\"\n";
    UrbanParser parser = new UrbanParser(expected);
    Story line = (Story) parser.line();
    assertEquals(expected, line.toString());
  }

  @Test
  public void testModification()  throws RecognitionException {
    String expected = "%mod: $T > 1.0 do \"foo\" := 5.0\n";
    UrbanParser parser = new UrbanParser(expected);
    Modification line = (Modification) parser.line();
    assertEquals(expected, line.toString());
  }
}
TOP

Related Classes of urban.parser.UrbanParserTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.