parset negative tests for all syntaxes
This commit is contained in:
parent
47199ca13c
commit
20c9de0380
@ -43,3 +43,13 @@
|
||||
(preprocess
|
||||
(pps bisect_ppx --conditional))
|
||||
(modules Unlexer))
|
||||
|
||||
(rule
|
||||
(targets Parser.msg)
|
||||
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
||||
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly )))
|
||||
|
||||
(rule
|
||||
(targets all.ligo)
|
||||
(deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe)
|
||||
(action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=ligo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly )))
|
@ -47,3 +47,13 @@
|
||||
(preprocess
|
||||
(pps bisect_ppx --conditional))
|
||||
(modules Unlexer))
|
||||
|
||||
(rule
|
||||
(targets Parser.msg)
|
||||
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
||||
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly )))
|
||||
|
||||
(rule
|
||||
(targets all.ligo)
|
||||
(deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe)
|
||||
(action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=ligo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly )))
|
||||
|
@ -1,7 +1,7 @@
|
||||
(ocamllex md)
|
||||
|
||||
(executables
|
||||
(names test doc_test)
|
||||
(names test doc_test parser_negative_tests)
|
||||
(libraries
|
||||
simple-utils
|
||||
ligo
|
||||
@ -23,7 +23,11 @@
|
||||
(alias
|
||||
(name parser-negative-tests)
|
||||
(action (run ./parser_negative_tests.exe))
|
||||
(deps ../passes/1-parser/pascaligo/all.ligo))
|
||||
(deps
|
||||
../passes/1-parser/pascaligo/all.ligo
|
||||
../passes/1-parser/cameligo/all.ligo
|
||||
../passes/1-parser/reasonligo/all.ligo
|
||||
))
|
||||
|
||||
(alias
|
||||
(name ligo-test)
|
||||
@ -34,7 +38,7 @@
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps (alias ligo-test) (alias doc-test))
|
||||
(deps (alias ligo-test) (alias doc-test) (alias parser-negative-tests))
|
||||
)
|
||||
|
||||
(alias
|
||||
|
41
src/test/parser_negative_tests.ml
Normal file
41
src/test/parser_negative_tests.ml
Normal file
@ -0,0 +1,41 @@
|
||||
open Test_helpers
|
||||
open Trace
|
||||
|
||||
type 'a sdata = { erroneous_source_file : string ; parser : string -> 'a result }
|
||||
let pascaligo_sdata = {
|
||||
erroneous_source_file = "../passes/1-parser/pascaligo/all.ligo" ;
|
||||
parser = Parser.Pascaligo.parse_expression }
|
||||
let cameligo_sdata = {
|
||||
erroneous_source_file = "../passes/1-parser/cameligo/all.ligo" ;
|
||||
parser = Parser.Cameligo.parse_expression }
|
||||
let reasonligo_sdata = {
|
||||
erroneous_source_file = "../passes/1-parser/reasonligo/all.ligo" ;
|
||||
parser = Parser.Reasonligo.parse_expression }
|
||||
|
||||
let get_exp_as_string filename =
|
||||
let lines = ref [] in
|
||||
let chan = open_in filename in
|
||||
try
|
||||
while true; do
|
||||
lines := input_line chan :: !lines
|
||||
done; !lines
|
||||
with End_of_file ->
|
||||
close_in chan;
|
||||
List.rev !lines ;;
|
||||
|
||||
let assert_syntax_error sdata () =
|
||||
let%bind _l = bind_iter_list
|
||||
(fun entry -> Assert.assert_fail @@ sdata.parser entry)
|
||||
(get_exp_as_string sdata.erroneous_source_file) in
|
||||
ok ()
|
||||
|
||||
let () =
|
||||
Printexc.record_backtrace true ;
|
||||
run_test @@ test_suite "LIGO" [
|
||||
test_suite "Parser negative tests" [
|
||||
test "pascaligo" @@ assert_syntax_error pascaligo_sdata ;
|
||||
test "cameligo" @@ assert_syntax_error cameligo_sdata ;
|
||||
test "reasonligo" @@ assert_syntax_error reasonligo_sdata ;
|
||||
]
|
||||
] ;
|
||||
()
|
Loading…
Reference in New Issue
Block a user