Package sizzle.types

Examples of sizzle.types.SizzleBool


public class TestFunctionTrie {
  @Test
  public void testFunctionTrieSingleParameter() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleString() });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt() }));

    Assert.assertEquals("did not return correct function", sizzleFunction, functionTrie.getFunction("function", new SizzleType[] { new SizzleString() }));
  }
View Full Code Here


  @Test
  public void testFunctionTrieMultiParameter() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt(), new SizzleFloat(), new SizzleString() });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleString(), new SizzleFloat(), new SizzleInt() }));

    Assert.assertEquals("did not return correct function", sizzleFunction,
        functionTrie.getFunction("function", new SizzleType[] { new SizzleInt(), new SizzleFloat(), new SizzleString() }));
  }
View Full Code Here

  @Test
  public void testFunctionTrieOverloadedArgsShort() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt() });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt(), new SizzleString() }));

    Assert.assertEquals("did not return correct function", sizzleFunction, functionTrie.getFunction("function", new SizzleType[] { new SizzleInt() }));
  }
View Full Code Here

  @Test
  public void testFunctionTrieOverloadedArgsLong() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt(), new SizzleString() });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt() }));

    Assert.assertEquals("did not return correct function", sizzleFunction,
        functionTrie.getFunction("function", new SizzleType[] { new SizzleInt(), new SizzleString() }));
  }
View Full Code Here

  @Test
  public void testFunctionTrieGeneric() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleAny() });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleInt() }));

    Assert.assertEquals("did not return correct function", sizzleFunction, functionTrie.getFunction("function", new SizzleType[] { new SizzleString() }));
  }
View Full Code Here

  @Test
  public void testFunctionTrieVarargs() {
    final FunctionTrie functionTrie = new FunctionTrie();

    final SizzleFunction sizzleFunction = new SizzleFunction(new SizzleBool(),
        new SizzleType[] { new SizzleString(), new SizzleVarargs(new SizzleString()) });

    functionTrie.addFunction("function", sizzleFunction);
    functionTrie.addFunction("function", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleString(), new SizzleVarargs(new SizzleInt()) }));

    Assert.assertEquals("did not return correct function", sizzleFunction,
        functionTrie.getFunction("function", new SizzleType[] { new SizzleString(), new SizzleString(), new SizzleString(), new SizzleString() }));
  }
View Full Code Here

      final SizzleType rtype = n.f0.accept(this, argu);

      if (!(rtype instanceof SizzleBool))
        throw new TypeException("invalid type " + rtype + " for disjunction");

      return new SizzleBool();
    }

    return ltype;
  }
View Full Code Here

      final SizzleType rhs = n.f0.accept(this, argu);

      if (!rhs.compares(lhs))
        throw new TypeException("invalid type " + rhs + " for conjunction with " + lhs);

      return new SizzleBool();
    }

    return lhs;
  }
View Full Code Here

      final SizzleType rhs = ((NodeSequence) n.f1.node).nodes.get(1).accept(this, argu);

      if (!rhs.compares(lhs))
        throw new TypeException("invalid type " + rhs + " for comparison with " + lhs);

      return new SizzleBool();
    }

    return lhs;
  }
View Full Code Here

    final SymbolTable st = new SymbolTable();

    SizzleParser.ReInit(new StringReader(source));
    TestTypeCheckingVisitor.typeChecker.visit(SizzleParser.Start(), st);

    Assert.assertEquals("my_bool is not an alias for bool", new SizzleName(new SizzleBool()), st.getType("my_bool"));
    final ArrayList<SizzleType> members = new ArrayList<SizzleType>(Arrays.asList(new SizzleFloat(), new SizzleFloat()));
    Assert.assertEquals("Coordinates is not is not an alias for a tuple of x: float, y: float", new SizzleName(new SizzleTuple(members)),
        st.getType("Coordinates"));
    Assert.assertEquals("CityMap is not an alias for a mapping from string to tuple of x: float, y: float", new SizzleName(new SizzleMap(
        new SizzleString(), new SizzleName(new SizzleTuple(members)))), st.getType("CityMap"));
View Full Code Here

TOP

Related Classes of sizzle.types.SizzleBool

Copyright © 2018 www.massapicom. 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.