diff --git a/build/build/src/enso.rs b/build/build/src/enso.rs index b1258c19c1d..40d2e27721c 100644 --- a/build/build/src/enso.rs +++ b/build/build/src/enso.rs @@ -1,6 +1,7 @@ use crate::prelude::*; use crate::paths::Paths; +use crate::paths::ENSO_ENABLE_ASSERTIONS; use crate::paths::ENSO_META_TEST_ARGS; use crate::paths::ENSO_META_TEST_COMMAND; use crate::postgres; @@ -119,6 +120,8 @@ impl BuiltEnso { ENSO_META_TEST_COMMAND.set(&self.wrapper_script_path())?; ENSO_META_TEST_ARGS.set(&format!("{} --run", ir_caches.flag()))?; + ENSO_ENABLE_ASSERTIONS.set("true")?; + // Prepare Engine Test Environment if let Ok(gdoc_key) = std::env::var("GDOC_KEY") { let google_api_test_data_dir = diff --git a/build/build/src/paths.rs b/build/build/src/paths.rs index afd5bab79df..c52809a091b 100644 --- a/build/build/src/paths.rs +++ b/build/build/src/paths.rs @@ -29,6 +29,9 @@ ide_ci::define_env_var! { /// Arguments to the engine runner. /// See: ENSO_META_TEST_ARGS, String; + + /// If Enso-specific assertions should be enabled. + ENSO_ENABLE_ASSERTIONS, String; } pub const EDITION_FILE_ARTIFACT_NAME: &str = "Edition File"; diff --git a/test/Tests/src/Main.enso b/test/Tests/src/Main.enso index f14a8ac24f3..1f69d9ec46a 100644 --- a/test/Tests/src/Main.enso +++ b/test/Tests/src/Main.enso @@ -65,6 +65,7 @@ import project.Network.Http_Spec import project.Network.URI_Spec import project.Runtime.Ascribed_Parameters_Spec +import project.Runtime.Asserts_Spec import project.Runtime.Lazy_Spec import project.Runtime.Lazy_Generator_Spec import project.Runtime.Managed_Resource_Spec @@ -132,6 +133,7 @@ main = Test_Suite.run_main <| Ref_Spec.spec Regex_Spec.spec Ascribed_Parameters_Spec.spec + Asserts_Spec.spec Lazy_Spec.spec Runtime_Spec.spec Self_Type_Spec.spec diff --git a/test/Tests/src/Runtime/Asserts_Spec.enso b/test/Tests/src/Runtime/Asserts_Spec.enso new file mode 100644 index 00000000000..3261df693a9 --- /dev/null +++ b/test/Tests/src/Runtime/Asserts_Spec.enso @@ -0,0 +1,27 @@ +from Standard.Base import all + +from Standard.Base.Errors.Common import Assertion_Error + +from Standard.Test import Test, Test_Suite +import Standard.Test.Extensions + +foreign js js_check = """ + return (4 == 2 + 2) + +on_ci = if Environment.get "ENSO_RUNNER_CONTAINER_NAME" . is_nothing . not then Nothing else "Not in CI" + +spec = Test.group "Asserts" pending=on_ci <| + Test.specify "should be enabled on the CI" <| + p = Panic.catch Assertion_Error (Runtime.assert False) err-> + err.payload + Meta.type_of p . should_be_a Assertion_Error + + Test.specify "should be able to take foreign functions as expressions" <| + ret = Runtime.assert js_check + ret . should_be_a Nothing + + Test.specify "should be able to take lambdas as expressions" <| + Runtime.assert <| + 4 == 2 + 2 + +main = Test_Suite.run_main spec