diff --git a/HACKING.md b/HACKING.md index 0a6745015d..66c8f053ef 100644 --- a/HACKING.md +++ b/HACKING.md @@ -147,14 +147,13 @@ directory. All `.ncl` files in this directory are automatically converted into Rust integration tests, which run the file and assert that no errors were raised during evaluation. -Each of these `.ncl` files is structured as an array of `Bool` expressions, which -is ultimately passed to a `check` function defined in -`core/tests/integration/pass/lib/assert.ncl`. -This function applies an `Assert` contract to each value in the array, which -checks that the value it is applied to evaluates to `true`. The benefit of using -a contract for this is that if a test fails we can simply run the file directly -using Nickel, which gives better error messages than the ones we get by default -from `cargo test`. +Each of these `.ncl` files is structured as an array of `Bool` expressions, +which is ultimately passed to `std.contract.check` function defined in the +standard library. This function applies an `Assert` (`std.test.Assert`) +contract to each value in the array, which checks that the value it is applied +to evaluates to `true`. The benefit of using a contract for this is that if a +test fails we can simply run the file directly using Nickel, which gives better +error messages than the ones we get by default from `cargo test`. Tests which are expected to fail may be written in Rust in `core/tests/integration`. However, simple failure test cases can make use of the test annotation support diff --git a/core/stdlib/std.ncl b/core/stdlib/std.ncl index fe3b16952a..08bec6f8e7 100644 --- a/core/stdlib/std.ncl +++ b/core/stdlib/std.ncl @@ -792,6 +792,28 @@ }, contract = { + Assert + | doc m%" + A contract that checks if its argument is the boolean true. + + We could get by just using arrays of boolean tests and `std.array.all`. + + However, this contract provides fine-grained error reporting, + pinpointoing the exact expression that failed in an array of tests, as + opposed to the pure boolean solution. + + # Examples + + ```nickel + 1 == 2 | std.test.Assert + => error: contract broken by a value + + 1 == 1 | std.test.Assert + => true + ``` + "% + = fun l x => if x then true else %blame% l, + Equal | doc m%" `Equal` is a contract enforcing equality to a given constant. @@ -3064,6 +3086,44 @@ = fun s => %enum_from_str% s, }, + test = { + Assert + | doc m%" + A contract that checks if its argument is the boolean true. + + # Examples + + ```nickel + 1 == 2 | std.test.Assert + => error: contract broken by a value + + 1 == 1 | std.test.Assert + => true + ``` + "% + = fun l x => if x then true else %blame% l, + + # We statically type `assert_all` because (x | Assert) is not of type bool. + # We could use additional contracts to make it work but it's not worth the + # hassle, given the size of the function. + assert_all + | doc m%" + Asserts that all the elements of an array are equal to true. Applies the + `std.test.Assert` contract on each element of the given array. + + Evalutes to `true` if all the elements of the array are equal to true, + or fails with a contract error otherwise. + + # Example + + ```nickel + [ (1 == 2), (1 == 1), (1 == 3) ] |> std.test.assert_all + => error: contract broken by a value + ``` + "% + = std.array.fold_left (fun acc test => (test | Assert) && acc) true, + }, + is_number : Dyn -> Bool | doc m%" diff --git a/core/tests/integration/inputs/adts/enum_primops.ncl b/core/tests/integration/inputs/adts/enum_primops.ncl index 9ff67836c0..eb7e261bae 100644 --- a/core/tests/integration/inputs/adts/enum_primops.ncl +++ b/core/tests/integration/inputs/adts/enum_primops.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ %enum_unwrap_variant% ('Left (1+1)) == 2, @@ -8,4 +8,4 @@ let {check, ..} = import "../lib/assert.ncl" in %enum_get_tag% 'Right == 'Right, %enum_get_tag% ('Right "stuff") == 'Right, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/contracts/contracts.ncl b/core/tests/integration/inputs/contracts/contracts.ncl index 8c4959a4e8..7dc66a6fa8 100644 --- a/core/tests/integration/inputs/contracts/contracts.ncl +++ b/core/tests/integration/inputs/contracts/contracts.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, Assert, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in [ let AlwaysTrue = fun l t => @@ -179,4 +179,4 @@ let {check, Assert, ..} = import "../lib/assert.ncl" in in tag == 'some_tag, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/contracts/let_order.ncl b/core/tests/integration/inputs/contracts/let_order.ncl index 3812b30d72..39f014ec01 100644 --- a/core/tests/integration/inputs/contracts/let_order.ncl +++ b/core/tests/integration/inputs/contracts/let_order.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, Assert, .. } = import "../lib/assert.ncl" in + let ConstantTrue = fun _label value => std.seq value true in [ let foo | ConstantTrue | Bool = "not a bool" in @@ -12,4 +12,4 @@ let ConstantTrue = fun _label value => std.seq value true in = "still not a bool" }.foo ] -|> check \ No newline at end of file +|> std.test.assert_all diff --git a/core/tests/integration/inputs/contracts/types_dont_propagate.ncl b/core/tests/integration/inputs/contracts/types_dont_propagate.ncl index 874be21308..def12e0f18 100644 --- a/core/tests/integration/inputs/contracts/types_dont_propagate.ncl +++ b/core/tests/integration/inputs/contracts/types_dont_propagate.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # check that a record type literal is indeed converted to the corresponding @@ -21,4 +21,4 @@ let {check, ..} = import "../lib/assert.ncl" in & {foo | force = false, bar | force = true}) == {foo = false, bar = true}, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/arrays.ncl b/core/tests/integration/inputs/core/arrays.ncl index fc99dee747..262f56842c 100644 --- a/core/tests/integration/inputs/core/arrays.ncl +++ b/core/tests/integration/inputs/core/arrays.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # accesses @@ -49,4 +49,4 @@ let {check, ..} = import "../lib/assert.ncl" in std.array.map_with_index (+) [1, 2, 3] == [1, 3, 5], ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/basics.ncl b/core/tests/integration/inputs/core/basics.ncl index eb332f866b..9fe46df898 100644 --- a/core/tests/integration/inputs/core/basics.ncl +++ b/core/tests/integration/inputs/core/basics.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # basic arithmetic @@ -35,4 +35,4 @@ let {check, ..} = import "../lib/assert.ncl" in # This test checks that the terms of a match are closured let x = 3 in ((3 + 2) |> match { 'foo => 1, _ => x}) == 3, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/builtins.ncl b/core/tests/integration/inputs/core/builtins.ncl index 9fef0b9924..dbf15127ed 100644 --- a/core/tests/integration/inputs/core/builtins.ncl +++ b/core/tests/integration/inputs/core/builtins.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # is_record @@ -28,4 +28,4 @@ let {check, ..} = import "../lib/assert.ncl" in |> std.deserialize 'Json == [3,4], ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/curried_dot.ncl b/core/tests/integration/inputs/core/curried_dot.ncl index 073b0bce12..83e04a94ea 100644 --- a/core/tests/integration/inputs/core/curried_dot.ncl +++ b/core/tests/integration/inputs/core/curried_dot.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let record = {foo = 1, bar = { baz = 2 }} in let field = "bar" in @@ -9,4 +9,4 @@ let part = "ba" in (.) record field == { baz = 2 }, let res = (.) record field == {baz = 2} in res, (.) record "%{part}r" == { baz = 2 }, -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/core/eq.ncl b/core/tests/integration/inputs/core/eq.ncl index f74dff94d2..f721373c3d 100644 --- a/core/tests/integration/inputs/core/eq.ncl +++ b/core/tests/integration/inputs/core/eq.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # basic @@ -84,4 +84,4 @@ let {check, ..} = import "../lib/assert.ncl" in 'Left 2 != 'Right 2, 'Up [1,2,3] == 'Up [0+1,1+1,2+1], ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/fibo.ncl b/core/tests/integration/inputs/core/fibo.ncl index 7d16f76478..771aa18f4c 100644 --- a/core/tests/integration/inputs/core/fibo.ncl +++ b/core/tests/integration/inputs/core/fibo.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {Assert, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in let Y | ((Number -> Number) -> Number -> Number) -> Number -> Number = fun f => (fun x => f (x x)) (fun x => f (x x)) in let dec : Number -> Number = fun x => x + (-1) in diff --git a/core/tests/integration/inputs/core/functions.ncl b/core/tests/integration/inputs/core/functions.ncl index 2e48a3008a..0c26f9c672 100644 --- a/core/tests/integration/inputs/core/functions.ncl +++ b/core/tests/integration/inputs/core/functions.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ (fun x => x) 3 == 3, @@ -16,4 +16,4 @@ let {check, ..} = import "../lib/assert.ncl" in g true == 4, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/import.ncl b/core/tests/integration/inputs/core/import.ncl index 1c37d0e047..acbb353672 100644 --- a/core/tests/integration/inputs/core/import.ncl +++ b/core/tests/integration/inputs/core/import.ncl @@ -1,3 +1,3 @@ # test.type = 'pass' -let { Assert, .. } = import "../lib/assert.ncl" in +let Assert = std.test.Assert in ((import "../lib/imported.ncl") 3 == 3 | Assert) diff --git a/core/tests/integration/inputs/core/numbers.ncl b/core/tests/integration/inputs/core/numbers.ncl index 8b0a59f819..d7a60e8003 100644 --- a/core/tests/integration/inputs/core/numbers.ncl +++ b/core/tests/integration/inputs/core/numbers.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ 5 + 5 == 10, @@ -7,4 +7,4 @@ let {check, ..} = import "../lib/assert.ncl" in 1e6 == 1000000, 1e+3 / 2e-3 == 0.5e6, ] -|> check \ No newline at end of file +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/records.ncl b/core/tests/integration/inputs/core/records.ncl index a53cb4e23e..a131e1c12d 100644 --- a/core/tests/integration/inputs/core/records.ncl +++ b/core/tests/integration/inputs/core/records.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, .. } = import "../lib/assert.ncl" in + [ # accesses @@ -171,4 +171,4 @@ let { check, .. } = import "../lib/assert.ncl" in && r.force == "no" ) ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/core/recursive_let.ncl b/core/tests/integration/inputs/core/recursive_let.ncl index d3715acca6..21428503a0 100644 --- a/core/tests/integration/inputs/core/recursive_let.ncl +++ b/core/tests/integration/inputs/core/recursive_let.ncl @@ -1,8 +1,8 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ let rec f = fun n => if n == 0 then n else f (n - 1) in f 10 == 0, let rec fib = fun n => if n == 0 || n == 1 then 1 else fib (n - 1) + fib (n - 2) in fib 5 == 8, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/imports/yaml_import.ncl b/core/tests/integration/inputs/imports/yaml_import.ncl index 93e4af8f9d..474b238417 100644 --- a/core/tests/integration/inputs/imports/yaml_import.ncl +++ b/core/tests/integration/inputs/imports/yaml_import.ncl @@ -1,6 +1,6 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ (import "imported/empty.yaml") == null, @@ -9,4 +9,4 @@ let {check, ..} = import "../lib/assert.ncl" in { type = "event", id = 2 } ], ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/lib/assert.ncl b/core/tests/integration/inputs/lib/assert.ncl deleted file mode 100644 index 54148ba808..0000000000 --- a/core/tests/integration/inputs/lib/assert.ncl +++ /dev/null @@ -1,31 +0,0 @@ -# test.type = 'skip' -{ - Assert | doc m%" - A contract that checks if its argument is the boolean true. - - We could get by just using arrays of boolean tests and `array.all`. - - However, we apply this contract to each test instead because it provides - fine-grained error reporting, pinpointoing the exact expression that failed - in an array of tests, as opposed to the pure boolean solution. - "% - = fun l x => x || %blame% l, - # We can't use a static type because x | Assert is not of type bool. - # We could use additional contracts to make it work but it's not worth the - # hassle. - check | doc m%" - unchecked type: Array Bool -> Bool - - Check an array of tests. Apply the `Assert` contract on each element of the - given array. - - `check tests` It is semantically equivalent to - - ```nickel - (array.all function.id tests) | Assert - ``` - - But will give more precise error reporting when one test fails. - "% - = std.array.fold_left (fun acc test => (test | Assert) && acc) true, -} diff --git a/core/tests/integration/inputs/merging/adts.ncl b/core/tests/integration/inputs/merging/adts.ncl index fa7ec12783..6d266257bf 100644 --- a/core/tests/integration/inputs/merging/adts.ncl +++ b/core/tests/integration/inputs/merging/adts.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, .. } = import "../lib/assert.ncl" in + [ 'Foo true & 'Foo true == 'Foo true, @@ -13,4 +13,4 @@ let { check, .. } = import "../lib/assert.ncl" in & { two.b = 1, one = 'Qux {c = 0} } == { one = 'Qux { a = 1, b = 1, c = 0 }, two = { a = 1, b = 1 } }, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/array-merge.ncl b/core/tests/integration/inputs/merging/array-merge.ncl index 514e4307c3..17a93d48ee 100644 --- a/core/tests/integration/inputs/merging/array-merge.ncl +++ b/core/tests/integration/inputs/merging/array-merge.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # array pointwise merging @@ -25,4 +25,4 @@ let {check, ..} = import "../lib/assert.ncl" in & ([0 + 0, 1 + 0, 2 + 0] | Array AddOne) == [1, 2, 3], ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/lazy-propagation.ncl b/core/tests/integration/inputs/merging/lazy-propagation.ncl index 75bde1bd13..6bb6789a7a 100644 --- a/core/tests/integration/inputs/merging/lazy-propagation.ncl +++ b/core/tests/integration/inputs/merging/lazy-propagation.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, Assert, ..} = import "../lib/assert.ncl" in + # tests related to RFC005. Check in particular that the motivating examples of # RFC005 are indeed fixed by lazy propagation. @@ -44,4 +44,4 @@ let {check, Assert, ..} = import "../lib/assert.ncl" in & {bar = "bar"}) == {foo = 5, bar = "bar"}, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/metavalues.ncl b/core/tests/integration/inputs/merging/metavalues.ncl index 3b28221167..8820d9ced2 100644 --- a/core/tests/integration/inputs/merging/metavalues.ncl +++ b/core/tests/integration/inputs/merging/metavalues.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, Assert, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in [ {val | default | Number = 10}.val == 10, @@ -132,4 +132,4 @@ let {check, Assert, ..} = import "../lib/assert.ncl" in (%fields% value == ["foo", "opt"] | Assert) ), ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/multiple_overrides.ncl b/core/tests/integration/inputs/merging/multiple_overrides.ncl index 8ebe7adbc5..3ef75e2908 100644 --- a/core/tests/integration/inputs/merging/multiple_overrides.ncl +++ b/core/tests/integration/inputs/merging/multiple_overrides.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # regression test for issue #908 (https://github.com/tweag/nickel/issues/908) @@ -121,6 +121,6 @@ let {check, ..} = import "../lib/assert.ncl" in fst_data = "override", snd_data = "override", } - ] |> check, + ] |> std.test.assert_all, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/overriding.ncl b/core/tests/integration/inputs/merging/overriding.ncl index b2170664d3..4a63cdee3f 100644 --- a/core/tests/integration/inputs/merging/overriding.ncl +++ b/core/tests/integration/inputs/merging/overriding.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ {foo | default = 1} & {foo = 2} == {foo = 2}, @@ -72,4 +72,4 @@ let {check, ..} = import "../lib/assert.ncl" in ({foo | default = 1, bar = foo} & {foo = 2}).bar == 2, ({foo | default = 1, bar = foo, baz = bar} & {foo = 2}).baz == 2, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/merging/priorities.ncl b/core/tests/integration/inputs/merging/priorities.ncl index b9899633ca..5d3d21daa1 100644 --- a/core/tests/integration/inputs/merging/priorities.ncl +++ b/core/tests/integration/inputs/merging/priorities.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {Assert, check, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in [ let block1 = { @@ -83,4 +83,4 @@ let {Assert, check, ..} = import "../lib/assert.ncl" in # } in # {val | rec force = x } & {val = {foo = 0, bar = 10}} # == {val = {bar = 10, foo = 1 + 2 + 10}} | Assert, -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/parsing/annotations.ncl b/core/tests/integration/inputs/parsing/annotations.ncl index ec86a45bf5..67e4d2f5c0 100644 --- a/core/tests/integration/inputs/parsing/annotations.ncl +++ b/core/tests/integration/inputs/parsing/annotations.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, Assert, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in [ # left_annot_precedence @@ -23,4 +23,4 @@ let {check, Assert, ..} = import "../lib/assert.ncl" in # others_precedence ((fun x => x | Assert) true), ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/parsing/identifiers.ncl b/core/tests/integration/inputs/parsing/identifiers.ncl index 22ff98bfaa..61448bedf8 100644 --- a/core/tests/integration/inputs/parsing/identifiers.ncl +++ b/core/tests/integration/inputs/parsing/identifiers.ncl @@ -1,8 +1,8 @@ # test.type = 'pass' -let {Assert, check, ..} = import "../lib/assert.ncl" in + [ let this-isn't-invalid = true in this-isn't-invalid, let ___multi_underscore_start = true in ___multi_underscore_start, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/arrays.ncl b/core/tests/integration/inputs/pattern-matching/arrays.ncl index f0d6f3fe83..b797f4993b 100644 --- a/core/tests/integration/inputs/pattern-matching/arrays.ncl +++ b/core/tests/integration/inputs/pattern-matching/arrays.ncl @@ -1,6 +1,4 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in - [ [] |> match { [x] => false, @@ -51,4 +49,4 @@ let {check, ..} = import "../lib/assert.ncl" in _ => false, } ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/basics.ncl b/core/tests/integration/inputs/pattern-matching/basics.ncl index 0f0ff908ce..dda27ebe65 100644 --- a/core/tests/integration/inputs/pattern-matching/basics.ncl +++ b/core/tests/integration/inputs/pattern-matching/basics.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ {foo = 1, bar = 2} |> match { @@ -59,4 +59,4 @@ let {check, ..} = import "../lib/assert.ncl" in |> eval {} |> (==) 11, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/contracts.ncl b/core/tests/integration/inputs/pattern-matching/contracts.ncl index d31afef755..bc6811dbb9 100644 --- a/core/tests/integration/inputs/pattern-matching/contracts.ncl +++ b/core/tests/integration/inputs/pattern-matching/contracts.ncl @@ -1,9 +1,9 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ {foo = {}} |> match { {foo = {bar ? 5}} => true}, {foo = {}} |> match { {foo = {bar | String }} => false, {foo} => true}, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/default_value.ncl b/core/tests/integration/inputs/pattern-matching/default_value.ncl index 66aa899b73..ea45bb8fdd 100644 --- a/core/tests/integration/inputs/pattern-matching/default_value.ncl +++ b/core/tests/integration/inputs/pattern-matching/default_value.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ let {x ? 1, y ? 1, z} = {z = 1} in (x + y + z) == 3, @@ -13,4 +13,4 @@ let {check, ..} = import "../lib/assert.ncl" in _ => false, }, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/enum_after_wildcard.ncl b/core/tests/integration/inputs/pattern-matching/enum_after_wildcard.ncl index c9efa32001..bbc17df2b1 100644 --- a/core/tests/integration/inputs/pattern-matching/enum_after_wildcard.ncl +++ b/core/tests/integration/inputs/pattern-matching/enum_after_wildcard.ncl @@ -8,7 +8,7 @@ # This test ensure it correctly handle a wildcard being used before the end of # the match expression, which was mishandled previously (branches after the # wildcard would be selected if they matched). -let {check, ..} = import "../lib/assert.ncl" in + [ 'Foo |> match { @@ -28,4 +28,4 @@ let {check, ..} = import "../lib/assert.ncl" in _ => false, }, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/guards.ncl b/core/tests/integration/inputs/pattern-matching/guards.ncl index f37b1bcc8b..e928920144 100644 --- a/core/tests/integration/inputs/pattern-matching/guards.ncl +++ b/core/tests/integration/inputs/pattern-matching/guards.ncl @@ -1,6 +1,4 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in - [ 'Ok |> match { 'Ok if false => false, @@ -29,4 +27,4 @@ let {check, ..} = import "../lib/assert.ncl" in _ => false } ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/pattern-matching/wildcards.ncl b/core/tests/integration/inputs/pattern-matching/wildcards.ncl index 7f849bbc77..baba74afcc 100644 --- a/core/tests/integration/inputs/pattern-matching/wildcards.ncl +++ b/core/tests/integration/inputs/pattern-matching/wildcards.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ {foo = 1, bar = 2} |> match { @@ -21,4 +21,4 @@ let {check, ..} = import "../lib/assert.ncl" in 'Point _ => true, }, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/records/record_defs.ncl b/core/tests/integration/inputs/records/record_defs.ncl index dd7fe59d54..d22913c57c 100644 --- a/core/tests/integration/inputs/records/record_defs.ncl +++ b/core/tests/integration/inputs/records/record_defs.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # piecewise_definitions @@ -41,4 +41,4 @@ let {check, ..} = import "../lib/assert.ncl" in let x = "foo" in {"%{x}" = bar, bar = 1} == {foo = 1, bar = 1}, ({"%foo"."%bar".baz = other + 1, other = 0}."%foo"."%bar".baz == 1), ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/serialization/serialize.ncl b/core/tests/integration/inputs/serialization/serialize.ncl index adfa0d1c90..6a285d1d7e 100644 --- a/core/tests/integration/inputs/serialization/serialize.ncl +++ b/core/tests/integration/inputs/serialization/serialize.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let assertSerInv = fun x => let assertAux = fun format x => @@ -63,4 +63,4 @@ let assertDeserInv = fun x => let ext = {foo = {some = {}}} in assertSerInv (base & ext), ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/record_empty_optional_ops.ncl b/core/tests/integration/inputs/stdlib/record_empty_optional_ops.ncl index 01cc078144..31a31a1aa4 100644 --- a/core/tests/integration/inputs/stdlib/record_empty_optional_ops.ncl +++ b/core/tests/integration/inputs/stdlib/record_empty_optional_ops.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, .. } = import "../lib/assert.ncl" in + let { record, .. } = std in [ @@ -23,4 +23,4 @@ let { record, .. } = std in std.record.has_field_with_opts "c" { a = 1, b = 2, c | optional } == true, std.record.has_field_with_opts "c" ({ a = 1, b = 2 } | { a, b, c | optional }) == true, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_contains_find_replace.ncl b/core/tests/integration/inputs/stdlib/string_contains_find_replace.ncl index b26cbbfd75..a9c3cca7db 100644 --- a/core/tests/integration/inputs/stdlib/string_contains_find_replace.ncl +++ b/core/tests/integration/inputs/stdlib/string_contains_find_replace.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -44,4 +44,4 @@ let {string, ..} = std in string.find "\\d" "no numeral" == { matched = "", index = -1, groups = []}, string.find "❀️" "πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨" == { matched = "", index = -1, groups = []}, string.find "❀️" "πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨β€οΈ" == { matched = "❀️", index = 1, groups = [] }, - ] |> check + ] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_contracts.ncl b/core/tests/integration/inputs/stdlib/string_contracts.ncl index 051edc888c..3d8eeb1077 100644 --- a/core/tests/integration/inputs/stdlib/string_contracts.ncl +++ b/core/tests/integration/inputs/stdlib/string_contracts.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -37,4 +37,4 @@ let {string, ..} = std in ("_" | string.NonEmpty) == "_", ("a" | string.NonEmpty) == "a", (" " | string.NonEmpty) == " ", -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_conversions.ncl b/core/tests/integration/inputs/stdlib/string_conversions.ncl index 694384d71e..76dabfcd33 100644 --- a/core/tests/integration/inputs/stdlib/string_conversions.ncl +++ b/core/tests/integration/inputs/stdlib/string_conversions.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -35,4 +35,4 @@ let {string, ..} = std in string.to_enum "X" == 'X, string.to_enum "X" == string.to_enum "X", string.to_enum "γ‚Ώγ‚°" == '"γ‚Ώγ‚°", -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_find.ncl b/core/tests/integration/inputs/stdlib/string_find.ncl index bef00b6641..2dd0a7a60d 100644 --- a/core/tests/integration/inputs/stdlib/string_find.ncl +++ b/core/tests/integration/inputs/stdlib/string_find.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, .. } = import "../lib/assert.ncl" in + let { string, .. } = std in [ @@ -8,4 +8,4 @@ let { string, .. } = std in std.string.find "(\\d+)\\.(\\d+)\\.(\\d+)" "1.2.3" == { groups = ["1", "2", "3"], index = 0, matched = "1.2.3" }, std.string.find "(\\p{Emoji})=(\\w+)" "πŸ˜€=smiling" == { groups = ["πŸ˜€", "smiling"], index = 0, matched = "πŸ˜€=smiling" } ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_find_all.ncl b/core/tests/integration/inputs/stdlib/string_find_all.ncl index 0a2c563b39..6124548112 100644 --- a/core/tests/integration/inputs/stdlib/string_find_all.ncl +++ b/core/tests/integration/inputs/stdlib/string_find_all.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let { check, .. } = import "../lib/assert.ncl" in + let { string, .. } = std in [ @@ -27,4 +27,4 @@ let { string, .. } = std in { groups = ["🫠", "melting"], index = 22, matched = "🫠=melting", } ] ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_primitives.ncl b/core/tests/integration/inputs/stdlib/string_primitives.ncl index 8ca7fe42f9..65e6d3b95a 100644 --- a/core/tests/integration/inputs/stdlib/string_primitives.ncl +++ b/core/tests/integration/inputs/stdlib/string_primitives.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -34,4 +34,4 @@ let {string, ..} = std in string.substring 0 1 "πŸ‘©πŸ»β€πŸ¦²" == "πŸ‘©πŸ»β€πŸ¦²", string.substring 1 6 "πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨hello" == "hello", string.substring 2 4 "abπŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨cd" == "πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨", -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_split_join.ncl b/core/tests/integration/inputs/stdlib/string_split_join.ncl index 93b3381430..574bb3b58d 100644 --- a/core/tests/integration/inputs/stdlib/string_split_join.ncl +++ b/core/tests/integration/inputs/stdlib/string_split_join.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -31,4 +31,4 @@ let {string, ..} = std in { sep = " ", str = "this is a sentence."}, { sep = "πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨", str = "-πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨-" }, ], -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_trim.ncl b/core/tests/integration/inputs/stdlib/string_trim.ncl index b817b58e26..025f752e1c 100644 --- a/core/tests/integration/inputs/stdlib/string_trim.ncl +++ b/core/tests/integration/inputs/stdlib/string_trim.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -19,4 +19,4 @@ let {string, ..} = std in "% == "a multiline string", -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/stdlib/string_uppercase_lowercase.ncl b/core/tests/integration/inputs/stdlib/string_uppercase_lowercase.ncl index b2f502102f..231ba5dc8b 100644 --- a/core/tests/integration/inputs/stdlib/string_uppercase_lowercase.ncl +++ b/core/tests/integration/inputs/stdlib/string_uppercase_lowercase.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let {string, ..} = std in [ @@ -32,4 +32,4 @@ let {string, ..} = std in "XXXXYYYYZZZZ", "THIS IS A TEST" ], -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/strings/string_interpolation.ncl b/core/tests/integration/inputs/strings/string_interpolation.ncl index b9f4f3ba10..24896e2058 100644 --- a/core/tests/integration/inputs/strings/string_interpolation.ncl +++ b/core/tests/integration/inputs/strings/string_interpolation.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + [ # Simple interpolation tests @@ -54,4 +54,4 @@ let {check, ..} = import "../lib/assert.ncl" in let actual = m%%"XYZ "%%%{"CBA"}""%% in let expected = "XYZ \"%CBA\"" in actual == expected, -] |> check +] |> std.test.assert_all diff --git a/core/tests/integration/inputs/strings/symbolic_strings.ncl b/core/tests/integration/inputs/strings/symbolic_strings.ncl index 7bf7c4e13e..4ab7727cdb 100644 --- a/core/tests/integration/inputs/strings/symbolic_strings.ncl +++ b/core/tests/integration/inputs/strings/symbolic_strings.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {check, ..} = import "../lib/assert.ncl" in + let sym = fun prefix_ fragments_ => { tag = 'SymbolicString, prefix = prefix_, fragments = fragments_ } in [ @@ -43,4 +43,4 @@ let sym = fun prefix_ fragments_ => { tag = 'SymbolicString, prefix = prefix_, f in actual == expected, ] -|> check +|> std.test.assert_all diff --git a/core/tests/integration/inputs/typecheck/basic_typechecking.ncl b/core/tests/integration/inputs/typecheck/basic_typechecking.ncl index 83c48cfbfc..ae5d6d7ce9 100644 --- a/core/tests/integration/inputs/typecheck/basic_typechecking.ncl +++ b/core/tests/integration/inputs/typecheck/basic_typechecking.ncl @@ -1,5 +1,5 @@ # test.type = 'pass' -let {Assert, ..} = import "../lib/assert.ncl" in +let Assert = std.test.Assert in (let plus : Number -> Number -> Number = fun x => fun y => x + y in plus (54 : Number) (6 : Number) == 60 | Assert) diff --git a/flake.lock b/flake.lock index 50d0fb8f5f..915dc22722 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "advisory-db": { "flake": false, "locked": { - "lastModified": 1712168594, - "narHash": "sha256-1Yh+vafNq19JDfmpknkWq11AkcQLPmFZ8X6YJZT5r7o=", + "lastModified": 1714183630, + "narHash": "sha256-1BVft7ggSN2XXFeXQjazU3jN9wVECd9qp2mZx/8GDMk=", "owner": "rustsec", "repo": "advisory-db", - "rev": "0bc9a77248be5cb5f2b51fe6aba8ba451d74c6bb", + "rev": "35e7459a331d3e0c585e56dabd03006b9b354088", "type": "github" }, "original": { @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1715274763, - "narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", + "lastModified": 1716156051, + "narHash": "sha256-TjUX7WWRcrhuUxDHsR8pDR2N7jitqZehgCVSy3kBeS8=", "owner": "ipetkov", "repo": "crane", - "rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", + "rev": "7443df1c478947bf96a2e699209f53b2db26209d", "type": "github" }, "original": { @@ -44,11 +44,11 @@ ] }, "locked": { - "lastModified": 1712180168, - "narHash": "sha256-sYe00cK+kKnQlVo1wUIZ5rZl9x8/r3djShUqNgfjnM4=", + "lastModified": 1715274763, + "narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", "owner": "ipetkov", "repo": "crane", - "rev": "06a9ff255c1681299a87191c2725d9d579f28b82", + "rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", "type": "github" }, "original": { @@ -241,11 +241,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1715361977, - "narHash": "sha256-j/PLYYGs+Gjge4JGYxMjOhWQEp+GB4Fdicetbpmp6n0=", + "lastModified": 1716186515, + "narHash": "sha256-BSvldBxypiYGuVuYfrIZNoM+tlkDsgQdz9HKe9e57v8=", "owner": "nixos", "repo": "nix", - "rev": "87ab3c0ea4e6f85e7b902050365bb75cf2836fbb", + "rev": "209d75529caaaf82a760056fc60156b9153af5c8", "type": "github" }, "original": { @@ -304,11 +304,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1715787315, - "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=", + "lastModified": 1715961556, + "narHash": "sha256-+NpbZRCRisUHKQJZF3CT+xn14ZZQO+KjxIIanH3Pvn4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5", + "rev": "4a6b83b05df1a8bd7d99095ec4b4d271f2956b64", "type": "github" }, "original": { @@ -409,11 +409,11 @@ ] }, "locked": { - "lastModified": 1715393623, - "narHash": "sha256-nSUFcUqyTQQ/aYFIB05mpCzytcKvfKMy3ZQAe0fP26A=", + "lastModified": 1716171463, + "narHash": "sha256-lc7wOh5BjYUoxdhcPkeUY8BmuL2qtRaHlW1403RW48E=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8eb8671512cb0c72c748058506e50c54fb5d8e2b", + "rev": "04d61d14803854fd8453ec43c5c53a471e5407a8", "type": "github" }, "original": { @@ -428,11 +428,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1712196778, - "narHash": "sha256-SOiwCr2HtmYpw8OvQQVRPtiCBWwndbIoPqtsamZK3J8=", + "lastModified": 1715739484, + "narHash": "sha256-5zlSuCM54jH6tXi8OILZ7opT+lBYUkGU9eOMEvJh9HU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "20e7895d1873cc64c14a9f024a8e04f5824bed28", + "rev": "3d27c65641a61d36f1c7616d6150524cd9a2a5f7", "type": "github" }, "original": { @@ -498,11 +498,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1712658781, - "narHash": "sha256-KWfgbVFV2zbCuNNFp9yeSgAa0Cc7cT090KK2J1ynfKg=", + "lastModified": 1715781565, + "narHash": "sha256-5o5DvwUYAmODYlFCuDJwRvEkitgq2SFD9Wy0DRMjKsY=", "owner": "tweag", "repo": "topiary", - "rev": "82a94a9f57104b89d4316afaeeab271cc51f7698", + "rev": "ba4f44062299cfc45d3c383e9697c325bedd0078", "type": "github" }, "original": {