Exemplo n.º 1
0
 public void testIHasAMixedCase() {
   CompilerState cs = new MockCompilerState();
   IHasACommand cmd = (IHasACommand) CommandFactory.instance().getCommand("I HAS A FisH");
   cmd.compile(cs);
   assertHasVar(cs, "FisH");
   assertNull(cmd.getExpression());
 }
Exemplo n.º 2
0
 public void testIHasAMixedCaseIsNotSame() {
   CompilerState cs = new MockCompilerState();
   cs.addVar("ALREADY");
   IHasACommand cmd = (IHasACommand) CommandFactory.instance().getCommand("I HAS A ALreadY");
   cmd.compile(cs);
   assertHasVar(cs, "ALreadY");
   assertHasVar(cs, "ALREADY");
 }
Exemplo n.º 3
0
 public void testIHasAWithValue() {
   CompilerState cs = new MockCompilerState();
   IHasACommand cmd = (IHasACommand) CommandFactory.instance().getCommand("I HAS A FISH ITZ 4");
   cmd.compile(cs);
   assertHasVar(cs, "FISH");
   assertNotNull(cmd.getExpression());
   assertInstanceOf(cmd.getExpression(), ValueExpression.class);
   assertEquals("4", cmd.getExpression().evaluate().strVal());
 }
Exemplo n.º 4
0
 public void testIHasAValueBadItz() {
   CompilerState cs = new MockCompilerState();
   Command cmd = CommandFactory.instance().getCommand("I HAS A FISH IZ 4");
   try {
     cmd.compile(cs);
     fail("Should have thrown exception.");
   } catch (ImproperCommandConstructionException e) {
     // yay
   }
 }
Exemplo n.º 5
0
 public void testIHasANoArg() {
   CompilerState cs = new MockCompilerState();
   Command cmd = CommandFactory.instance().getCommand("I HAS A ");
   try {
     cmd.compile(cs);
     fail("Should have thrown exception.");
   } catch (MissingIdentifierException e) {
     // yay
   }
 }
Exemplo n.º 6
0
 public void testIHasAKeyword() {
   CompilerState cs = new MockCompilerState();
   Command cmd = CommandFactory.instance().getCommand("I HAS A " + Univar.TRUE);
   try {
     cmd.compile(cs);
     fail("Should have thrown exception.");
   } catch (BadIdentifierException e) {
     // yay
   }
 }
Exemplo n.º 7
0
 public void testIHasAAlready() {
   CompilerState cs = new MockCompilerState();
   cs.addVar("ALREADY");
   Command cmd = CommandFactory.instance().getCommand("I HAS A ALREADY");
   try {
     cmd.compile(cs);
     fail("Should have thrown exception.");
   } catch (IdentifierAlreadyDeclaredException e) {
     // yay
   }
 }