using Test include("ASPLang.jl") using .ASPLang @testset "invalid term" begin @test_throws "" parse_asp("", term_grammar) @test_throws "" parse_asp("1+", term_grammar) @test_throws "" parse_asp("()", term_grammar) @test_throws "" parse_asp("(", term_grammar) @test_throws "" parse_asp(")", term_grammar) @test_throws "" parse_asp("[]", term_grammar) @test_throws "" parse_asp("[", term_grammar) @test_throws "" parse_asp("]", term_grammar) @test_throws "" parse_asp("{}", term_grammar) @test_throws "" parse_asp("{", term_grammar) @test_throws "" parse_asp("}", term_grammar) @test_throws "" parse_asp("1+()", term_grammar) @test_throws "" parse_asp("1<2", term_grammar) @test_throws "" parse_asp("1a", term_grammar) @test_throws "" parse_asp("1+(a+", term_grammar) @test_throws "" parse_asp("1+(1+))", term_grammar) @test_throws "" parse_asp("(1+(1)()", term_grammar) end @testset "variable" begin @test parse_asp("A", term_grammar) == Variable("A") @test parse_asp("A_a1b_2", term_grammar) == Variable("A_a1b_2") @test parse_asp("a", term_grammar) != Variable("a") @test_throws "" parse_asp("", term_grammar) != Variable("") end @testset "string constant" begin @test parse_asp("\"\"", term_grammar) == StringConstant("") @test parse_asp("\"A\"", term_grammar) == StringConstant("A") @test parse_asp("\"a\"", term_grammar) == StringConstant("a") @test parse_asp("\"1\"", term_grammar) == StringConstant("1") @test parse_asp("\"A_a1b_2\"", term_grammar) == StringConstant("A_a1b_2") end @testset "symbolic constant" begin @test parse_asp("a", term_grammar) == SymbolicConstant("a") @test parse_asp("a_A1B_2", term_grammar) == SymbolicConstant("a_A1B_2") @test parse_asp("A", term_grammar) != SymbolicConstant("A") end