From 75e63449728a178d7b5a85c02a9e6d1d1ec33f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 6 Jan 2020 18:05:25 +0100 Subject: [PATCH 1/2] Move the last two negative tests to a subdirectory, actually check that they fail in the expected way --- src/bin/expect_tests/syntax_error_tests.ml | 7 +++++++ src/bin/expect_tests/typer_error_tests.ml | 3 +++ .../contracts/{ => negative}/error_syntax.ligo | 0 .../contracts/{ => negative}/error_type.ligo | 0 src/test/dune | 2 +- src/test/manual_test.ml | 17 ----------------- 6 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 src/bin/expect_tests/syntax_error_tests.ml rename src/test/contracts/{ => negative}/error_syntax.ligo (100%) rename src/test/contracts/{ => negative}/error_type.ligo (100%) delete mode 100644 src/test/manual_test.ml diff --git a/src/bin/expect_tests/syntax_error_tests.ml b/src/bin/expect_tests/syntax_error_tests.ml new file mode 100644 index 000000000..3f7e78221 --- /dev/null +++ b/src/bin/expect_tests/syntax_error_tests.ml @@ -0,0 +1,7 @@ +open Cli_expect + +let%expect_test _ = + run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ; + [%expect {| + ligo: parser error: Parse error at "-" from (1, 16) to (1, 17). In file "|../../test/contracts/negative/error_syntax.ligo" + {"parser_loc":"in file \"\", line 1, characters 16-17"} |} ] ; diff --git a/src/bin/expect_tests/typer_error_tests.ml b/src/bin/expect_tests/typer_error_tests.ml index 2fcc7f4e5..d34657cb3 100644 --- a/src/bin/expect_tests/typer_error_tests.ml +++ b/src/bin/expect_tests/typer_error_tests.ml @@ -1,6 +1,9 @@ open Cli_expect let%expect_test _ = + run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_type.ligo" ; "main" ] ; + [%expect {| ligo: in file "error_type.ligo", line 3, characters 18-28. Adding with wrong types. Expected nat, int or tez. |} ] ; + run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_1.mligo" ; "main" ] ; [%expect {| ligo: in file "error_typer_1.mligo", line 3, characters 19-27. different type constructors: Expected these two constant type constructors to be the same, but they're different {"a":"string","b":"int"} diff --git a/src/test/contracts/error_syntax.ligo b/src/test/contracts/negative/error_syntax.ligo similarity index 100% rename from src/test/contracts/error_syntax.ligo rename to src/test/contracts/negative/error_syntax.ligo diff --git a/src/test/contracts/error_type.ligo b/src/test/contracts/negative/error_type.ligo similarity index 100% rename from src/test/contracts/error_type.ligo rename to src/test/contracts/negative/error_type.ligo diff --git a/src/test/dune b/src/test/dune index 9da57c8ef..b600a1fa3 100644 --- a/src/test/dune +++ b/src/test/dune @@ -1,7 +1,7 @@ (ocamllex md) (executables - (names test manual_test doc_test) + (names test doc_test) (libraries simple-utils ligo diff --git a/src/test/manual_test.ml b/src/test/manual_test.ml deleted file mode 100644 index fdf8d4d8d..000000000 --- a/src/test/manual_test.ml +++ /dev/null @@ -1,17 +0,0 @@ -open Trace -open Ligo.Run -open Test_helpers - -let syntax_error () : unit result = - let%bind _program = type_file `pascaligo "./contracts/error_syntax.ligo" in - ok () - -let type_error () : unit result = - let%bind _program = type_file `pascaligo "./contracts/error_type.ligo" in - ok () - -let () = - List.iter wrap_test_raw [ - type_error ; - syntax_error ; - ] From 8e18c1f8bd4e432c63d3df306dc1d3611e5c9a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Thu, 9 Jan 2020 18:59:10 +0100 Subject: [PATCH 2/2] update tests with the helper blurb --- src/bin/expect_tests/syntax_error_tests.ml | 12 +++++++++++- src/bin/expect_tests/typer_error_tests.ml | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/bin/expect_tests/syntax_error_tests.ml b/src/bin/expect_tests/syntax_error_tests.ml index 3f7e78221..7082dbcf9 100644 --- a/src/bin/expect_tests/syntax_error_tests.ml +++ b/src/bin/expect_tests/syntax_error_tests.ml @@ -4,4 +4,14 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ; [%expect {| ligo: parser error: Parse error at "-" from (1, 16) to (1, 17). In file "|../../test/contracts/negative/error_syntax.ligo" - {"parser_loc":"in file \"\", line 1, characters 16-17"} |} ] ; + {"parser_loc":"in file \"\", line 1, characters 16-17"} + + + If you're not sure how to fix this error, you can + do one of the following: + + * Visit our documentation: https://ligolang.org/docs/intro/what-and-why/ + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; + diff --git a/src/bin/expect_tests/typer_error_tests.ml b/src/bin/expect_tests/typer_error_tests.ml index d34657cb3..55f182c97 100644 --- a/src/bin/expect_tests/typer_error_tests.ml +++ b/src/bin/expect_tests/typer_error_tests.ml @@ -2,7 +2,16 @@ open Cli_expect let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_type.ligo" ; "main" ] ; - [%expect {| ligo: in file "error_type.ligo", line 3, characters 18-28. Adding with wrong types. Expected nat, int or tez. |} ] ; + [%expect {| + ligo: in file "error_type.ligo", line 3, characters 18-28. Adding with wrong types. Expected nat, int or tez. + + If you're not sure how to fix this error, you can + do one of the following: + + * Visit our documentation: https://ligolang.org/docs/intro/what-and-why/ + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_1.mligo" ; "main" ] ; [%expect {|