Exemplo n.º 1
0
func Test_ShouldReturnNilJustEOF(t *testing.T) {
	_, ch := lex.NewLexer("")
	p := NewParser(ch)
	if tree := p.Parse(); tree != nil {
		t.Errorf("Parse on empty string should only return nil, got %v instead", tree)
	}
}
Exemplo n.º 2
0
func Test_IntegerShouldReturnIntegerLiterals(t *testing.T) {
	_, ch := lex.NewLexer("123")
	p := NewParser(ch)
	if tree := p.Parse(); tree.Eval() != 123 {
		t.Errorf("Parse Expected to produce %v, got %v", 123, tree.Eval())
	}
}