Exemplo n.º 1
0
func TestParseEox(test *testing.T) {
	const input = `
`
	parser := NewParserForText(input)
	Assert(test, parser.ParseEOX(), "Could not parse EOX")
	tree.Display(parser.Ast)
}
Exemplo n.º 2
0
func TestParseProgram(test *testing.T) {
	const input = `val + 10 * z. open door.
	`
	parser := NewParserForText(input)
	Assert(test, parser.ParseProgram(), "Could not parse program.")
	tree.Display(parser.Ast)
}
Exemplo n.º 3
0
func TestParseStatements(test *testing.T) {
	const input = `val + 10 * z. open door.
	`
	parser := NewParserForText(input)
	Assert(test, parser.ParseStatements(), "Could not parse statements with only a parse word expression with operators")
	tree.Display(parser.Ast)
}
Exemplo n.º 4
0
func TestParseWordExpression2(test *testing.T) {
	const input = `val + 10 * z
	`
	parser := NewParserForText(input)
	Assert(test, parser.ParseWordExpression(), "Could not parse word expression with operators")
	tree.Display(parser.Ast)
}
Exemplo n.º 5
0
func TestParseWordExpression(test *testing.T) {
	const input = `say "hello world" three times
	`
	parser := NewParserForText(input)
	Assert(test, parser.ParseWordExpression(), "Could not parse word expression")
	tree.Display(parser.Ast)
}
Exemplo n.º 6
0
func TestParseParenthesis(test *testing.T) {
	// monolog.Setup("raku_test.log", true, false)
	const input = `(3 + 4 * 5)`
	parser := NewParserForText(input)
	Assert(test, parser.ParseParenthesis(), "Could not parse parenthesis.")
	tree.Display(parser.Ast)
	parser.Ast.Dotty()
}
Exemplo n.º 7
0
func TestParseProgram3(test *testing.T) {
	// monolog.Setup("raku_test.log", true, false)
	const input = `set foo to (3 + 4)
`
	parser := NewParserForText(input)
	Assert(test, parser.ParseProgram(), "Could not parse program.")
	tree.Display(parser.Ast)
	parser.Ast.Dotty()
}
Exemplo n.º 8
0
func TestParseblock(test *testing.T) {
	// monolog.Setup("raku_test.log", true, false)
	const input = `{
say "hello"
say "world"
let i be 3 + 4
let j be 7 + 5
let ij be i * j
return ij
}
`
	parser := NewParserForText(input)
	Assert(test, parser.ParseBlock(), "Could not parse block.")
	tree.Display(parser.Ast)
	// parser.Ast.Dotty()
}
Exemplo n.º 9
0
func TestParseProgram2(test *testing.T) {
	const input = `to greet someone  {
say "hello" someone
}

greet bob

if mp < cost do
	say "Not enough mana!"
end else do
	say "Zap!"
end

`
	parser := NewParserForText(input)
	Assert(test, parser.ParseProgram(), "Could not parse program.")
	tree.Display(parser.Ast)
}
Exemplo n.º 10
0
func TestParseValue3(test *testing.T) {
	const input = `$sym`
	parser := NewParserForText(input)
	Assert(test, parser.ParseValue(), "Could not parse value")
	tree.Display(parser.Ast)
}
Exemplo n.º 11
0
func TestParseValue(test *testing.T) {
	const input = `"hello \"world\\"`
	parser := NewParserForText(input)
	Assert(test, parser.ParseValue(), "Could not parse value")
	tree.Display(parser.Ast)
}
Exemplo n.º 12
0
func TestParseWord(test *testing.T) {
	const input = `say`
	parser := NewParserForText(input)
	Assert(test, parser.ParseWord(), "Could not parse word")
	tree.Display(parser.Ast)
}