diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Boolean.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Boolean.enso new file mode 100644 index 000000000000..adeb64f37d69 --- /dev/null +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Boolean.enso @@ -0,0 +1,131 @@ +## Booleans. +type Boolean + + ## A type with only two possible values. FIXME REMOVE? + + The boolean type represents the two truth values of boolean logic. It is + primarily used for control-flow. + @Builtin_Type + type Boolean + + ## Compares two booleans for equality. + + Arguments: + - that: The boolean to compare this with. + + > Example + Comparing True to False to get False. + + True == False + == : Boolean -> Boolean + == that = @Builtin_Method "Boolean.==" + + ## Computes the logical and (conjunction) of two booleans. + + Arguments: + - that: The boolean to compute the conjunction of this with. + + ! Short Circuiting + This method is not implemented in a short-circuiting manner. This means + that even if this is False, it will also evaluate that. This is + for performance. + + > Example + Computing the conjunction of False and True (to get False). + + False && True + && : Boolean -> Boolean + && that = @Builtin_Method "Boolean.&&" + + ## Computes the logical or (disjunction) of two booleans. + + Arguments: + - that: The boolean to compute the disjunction of this with. + + ! Short Circuiting + This method is not implemented in a short-circuiting manner. This means + that even if this is True, it will also evaluate that. This is + for performance. + + > Example + Computing the disjunction of True and False (to get True). + + True || False + || : Boolean -> Boolean + || that = @Builtin_Method "Boolean.||" + + ## Compares two booleans and returns an ordering value. + + Arguments: + - that: The boolean to compare with the value of this. + + ! Short Circuiting + This method is not implemented in a short-circuiting manner. This means + that even if this is False, it will also evaluate that. This is + for performance. + + > Example + Computing the ordering of True and False (to get Greater). + + True.compare_to False + compare_to : Boolean -> Ordering + compare_to that = @Builtin_Method "Boolean.compare_to" + + ## Computes the logical negation of this. + + > Example + Negating True to get False. + + True.not + not : Boolean + not = @Builtin_Method "Boolean.not" + + ## Generates a human-readable text representation of the boolean. + + > Example + Converting the value True to text. + + True.to_text + to_text : Text + to_text = @Builtin_Method "Boolean.to_text" + +## The if-then-else control flow operator that executes one of two branches + based on a conditional. + + Arguments: + - on_true: The computation to evaluate if this evaluates to True. + - on_false: The computation to evaluate if this evaluates to False. + + Both of the arguments to this method are _lazy_, meaning that they will + only be evaluated if they are needed (based on the condition). + + > Example + Telling the user if a number 27 is divisible by three. + + if (27 % 3) == 0 then IO.println "Yes" else IO.println "No" +if_then_else : Any -> Any -> Any +if_then_else ~on_true ~on_false = @Builtin_Method "Boolean.if_then_else" + +## The if-then control flow operator that executes a branch if the condition + is true, and otherwise returns Nothing. + + Arguments: + - on_true: The computation to evaluate if this evaluates to True. + + The argument to this method is _lazy_, meaning that it will only be + evaluated if the this evaluates to True. + + > Example + Printing a message to the user only if a number is divisible by three. + + if (27 % 3) == 0 then IO.println "Fizz" +if_then : Any -> Any | Nothing +if_then ~on_true = @Builtin_Method "Boolean.if_then" + +## The constructor for the value True. +@Builtin_Type +type True + +## The constructor for the value False. +@Builtin_Type +type False diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/List.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/List.enso index f28e03968131..87a117c61799 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/List.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/List.enso @@ -1,5 +1,6 @@ from Standard.Builtins import all from Standard.Builtins export Nil, Cons +from Standard.Base.Data.Boolean import all ## The basic cons-list type. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso index 3b54d22dca84..c20fb8ec54fb 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso @@ -1,3 +1,4 @@ +import project.Data.Boolean import project.Data.Any.Extensions import project.Data.Array import project.Data.Interval @@ -29,7 +30,7 @@ import project.System.File import project.Data.Text.Regex.Mode as Regex_Mode import project.Warning -from Standard.Builtins import Nothing, Number, Integer, Any, True, False, Cons, Boolean, Arithmetic_Error +from Standard.Builtins import Nothing, Number, Integer, Any, Cons, Arithmetic_Error export project.Data.Interval export project.Data.Json @@ -47,6 +48,7 @@ export project.System.File export project.Data.Text.Regex.Mode as Regex_Mode export project.Warning +from project.Data.Boolean export all from project.Data.Array export Array from project.Data.Any.Extensions export all from project.Data.List export Nil, Cons diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Bool.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Bool.java index dd5cdf2be930..8e353a2ee1da 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Bool.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Bool.java @@ -10,6 +10,7 @@ public class Bool { private final AtomConstructor tru; private final AtomConstructor fls; private final AtomConstructor bool; + private final Builtins builtins; /** * Creates and registers all the boolean constructors. @@ -17,8 +18,12 @@ public class Bool { * @param language the current language instance. * @param scope the scope to register constructors and methods in. */ - public Bool(Language language, ModuleScope scope) { - bool = new AtomConstructor("Boolean", scope).initializeFields(); + public Bool(Builtins builtins, Language language, ModuleScope scope) { + this.builtins = builtins; + tru = null; + fls = null; + bool = null; + /*bool = new AtomConstructor("Boolean", scope).initializeFields(); scope.registerConstructor(bool); scope.registerMethod(bool, "if_then_else", IfThenElseMethodGen.makeFunction(language)); scope.registerMethod(bool, "if_then", IfThenMethodGen.makeFunction(language)); @@ -31,21 +36,21 @@ public Bool(Language language, ModuleScope scope) { tru = new AtomConstructor("True", scope).initializeFields(); scope.registerConstructor(tru); fls = new AtomConstructor("False", scope).initializeFields(); - scope.registerConstructor(fls); + scope.registerConstructor(fls);*/ } /** @return the atom constructor for {@code True}. */ public AtomConstructor getTrue() { - return tru; + return builtins.getBuiltinType("True"); } /** @return the atom constructor for {@code False}. */ public AtomConstructor getFalse() { - return fls; + return builtins.getBuiltinType("False"); } /** @return the atom constructor for {@code Boolean}. */ public AtomConstructor getBool() { - return bool; + return builtins.getBuiltinType("Boolean"); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Builtins.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Builtins.java index bcfea9020eb9..c4178be871e0 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Builtins.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Builtins.java @@ -109,7 +109,7 @@ public Builtins(Context context) { builtinTypes = new HashMap<>(); any = new AtomConstructor("Any", scope).initializeFields(); - bool = new Bool(language, scope); + bool = new Bool(this, language, scope); debug = new AtomConstructor("Debug", scope).initializeFields(); dataflowError = new DataflowError(language, scope); Warning.initWarningMethods(language, scope); diff --git a/engine/runtime/src/main/resources/Builtins.enso b/engine/runtime/src/main/resources/Builtins.enso index 89a58b6c392c..52fc23c48d0c 100644 --- a/engine/runtime/src/main/resources/Builtins.enso +++ b/engine/runtime/src/main/resources/Builtins.enso @@ -4,121 +4,6 @@ # for that builtin in this file. If that is not done, it will fail to resolve # properly at runtime. -## Booleans. -type Boolean - - ## A type with only two possible values. - - The boolean type represents the two truth values of boolean logic. It is - primarily used for control-flow. - @Builtin_Type - type Boolean - - ## Compares two booleans for equality. - - Arguments: - - that: The boolean to compare this with. - - > Example - Comparing True to False to get False. - - True == False - == : Boolean -> Boolean - == that = @Builtin_Method "Boolean.==" - - ## Computes the logical and (conjunction) of two booleans. - - Arguments: - - that: The boolean to compute the conjunction of this with. - - ! Short Circuiting - This method is not implemented in a short-circuiting manner. This means - that even if this is False, it will also evaluate that. This is - for performance. - - > Example - Computing the conjunction of False and True (to get False). - - False && True - && : Boolean -> Boolean - && that = @Builtin_Method "Boolean.&&" - - ## Computes the logical or (disjunction) of two booleans. - - Arguments: - - that: The boolean to compute the disjunction of this with. - - ! Short Circuiting - This methid is not implemented in a short-circuiting manner. This means - that even if this is True, it will also evaluate that. This is - for performance. - - > Example - Computing the disjunction of True and False (to get True). - - True || False - || : Boolean -> Boolean - || that = @Builtin_Method "Boolean.||" - - ## Computes the logical negation of this. - - > Example - Negating True to get False. - - True.not - not : Boolean - not = @Builtin_Method "Boolean.not" - - ## Generates a human-readable text representation of the boolean. - - > Example - Converting the value True to text. - - True.to_text - to_text : Text - to_text = @Builtin_Method "Boolean.to_text" - - ## The if-then-else control flow operator that executes one of two branches - based on a conditional. - - Arguments: - - on_true: The computation to evaluate if this evaluates to True. - - on_false: The computation to evaluate if this evaluates to False. - - Both of the arguments to this method are _lazy_, meaning that they will - only be evaluated if they are needed (based on the condition). - - > Example - Telling the user if a number 27 is divisible by three. - - if (27 % 3) == 0 then IO.println "Yes" else IO.println "No" - if_then_else : Any -> Any -> Any - if_then_else ~on_true ~on_false = @Builtin_Method "Boolean.if_then_else" - - ## The if-then control flow operator that executes a branch if the condition - is true, and otherwise returns Nothing. - - Arguments: - - on_true: The computation to evaluate if this evaluates to True. - - The argument to this method is _lazy_, meaning that it will only be - evaluated if the this evaluates to True. - - > Example - Printing a message to the user only if a number is divisible by three. - - if (27 % 3) == 0 then IO.println "Fizz" - if_then : Any -> Any | Nothing - if_then ~on_true = @Builtin_Method "Boolean.if_then" - -## The constructor for the value True. -@Builtin_Type -type True - -## The constructor for the value False. -@Builtin_Type -type False - ## Debug utilities. type Debug diff --git a/engine/runtime/src/main/scala/org/enso/compiler/codegen/IrToTruffle.scala b/engine/runtime/src/main/scala/org/enso/compiler/codegen/IrToTruffle.scala index d4fff69d4954..468a6cda39a1 100644 --- a/engine/runtime/src/main/scala/org/enso/compiler/codegen/IrToTruffle.scala +++ b/engine/runtime/src/main/scala/org/enso/compiler/codegen/IrToTruffle.scala @@ -1,6 +1,6 @@ package org.enso.compiler.codegen -import com.oracle.truffle.api.Truffle +import com.oracle.truffle.api.{RootCallTarget, Truffle} import com.oracle.truffle.api.frame.FrameSlot import com.oracle.truffle.api.source.{Source, SourceSection} import org.enso.compiler.core.IR @@ -36,6 +36,7 @@ import org.enso.interpreter.{Constants, Language} import java.math.BigInteger import org.enso.compiler.core.IR.Name.Special +import org.enso.interpreter.runtime.builtin.Bool import org.enso.pkg.QualifiedName import scala.collection.{immutable, mutable} @@ -855,6 +856,9 @@ class IrToTruffle( // (array: AtomConstructor, branch: RootCallTarget) -> BranchNode // and related eta-expansion appear to crash Graal (not a joke). private val branchNodeFactories: Map[(QualifiedName, String), BranchNodeFactory] = immutable.HashMap[(QualifiedName, String), BranchNodeFactory]( + (QualifiedName(List("Standard", "Base"), "Boolean"), "True") -> { case (_: AtomConstructor, target: RootCallTarget) => BooleanBranchNode.build(true, target)}, + (QualifiedName(List("Standard", "Base"), "Boolean"), "False") -> { case (_: AtomConstructor, target: RootCallTarget) => BooleanBranchNode.build(false, target)}, + (QualifiedName(List("Standard", "Base"), "Boolean"), "Boolean") -> { case (bool: AtomConstructor, target: RootCallTarget) => BooleanConstructorBranchNode.build(bool.asInstanceOf[Bool], target)}, (QualifiedName(List("Standard", "Base"), "Polyglot"), "Polyglot") -> PolyglotBranchNode.build _, (QualifiedName(List("Standard", "Base", "Data"), "Array"), "Array") -> ArrayBranchNode.build _, ) diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/ConstructorsTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/ConstructorsTest.scala index 307150a5f9a1..cb63431f9f2e 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/ConstructorsTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/ConstructorsTest.scala @@ -29,6 +29,7 @@ class ConstructorsTest extends InterpreterTest { "work with recursion" in { val testCode = """from Standard.Builtins import all + |from Standard.Base import all | |main = | genList = i -> if i == 0 then Nil else Cons i (genList (i - 1)) diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/EvalTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/EvalTest.scala index 1baa0c0766c4..8d18ee864e29 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/EvalTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/EvalTest.scala @@ -66,6 +66,7 @@ class EvalTest extends InterpreterTest { "work in a recursive setting" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | fn = sumTo -> @@ -80,6 +81,7 @@ class EvalTest extends InterpreterTest { "work inside a thunk passed to another function" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | fn = sumTo -> diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/GlobalScopeTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/GlobalScopeTest.scala index 4da75318f52f..8b9755c92d21 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/GlobalScopeTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/GlobalScopeTest.scala @@ -59,6 +59,7 @@ class GlobalScopeTest extends InterpreterTest { "be able to mutually recurse in the global scope" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |Nothing.decrementCall = number -> | res = number - 1 diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala index b79f6a1beb7b..5a38feae769e 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala @@ -20,6 +20,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "echo" Array.empty "" False False False @@ -34,6 +35,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_1 "/c") "" False False False @@ -48,6 +50,8 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all + | |main = System.create_process "nonexistentcommandxyz" Array.empty "" False False False |""".stripMargin @@ -61,6 +65,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "ls" (Array.new_1 "--gibberish") "" False False False @@ -76,6 +81,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_2 "/c" "exit 7") "" False False False @@ -91,6 +97,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "read line; echo $line") "" True True True @@ -107,6 +114,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "PowerShell" (Array.new_2 "-Command" "[System.Console]::ReadLine()") "" True True True @@ -124,6 +132,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "wc -c") "" True True True @@ -140,6 +149,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "echo" (Array.new_1 "42") "" True True True @@ -156,6 +166,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_2 "/c" "echo 9") "" True True True @@ -172,6 +183,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "echo" (Array.new_1 "9") "" True True True @@ -187,6 +199,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_2 "/c" "echo 9") "" True True True @@ -202,6 +215,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "read line; printf $line") "hello" False False False @@ -217,6 +231,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "PowerShell" (Array.new_2 "-Command" "[System.Console]::ReadLine()") "hello" False False False @@ -232,6 +247,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "echo" (Array.new_1 "foobar") "" False True True @@ -247,6 +263,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_2 "/c" "echo foobar") "" False True True @@ -262,6 +279,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "printf '%b' '\x01\x0F\x10'") "" False True True @@ -277,6 +295,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "echo" (Array.new_1 "foobar") "" False False False @@ -293,6 +312,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "cmd" (Array.new_2 "/c" "echo foobar") "" False False False @@ -309,6 +329,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "printf err 1>&2") "" False True True @@ -324,6 +345,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "PowerShell" (Array.new_2 "-Command" "[System.Console]::Error.WriteLine('err')") "" False True True @@ -339,6 +361,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "printf '%b' '\xCA\xFE\xBA\xBE' 1>&2") "" False True True @@ -354,6 +377,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "bash" (Array.new_2 "-c" "printf err 1>&2") "" False False False @@ -369,6 +393,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { val code = """from Standard.Builtins import all |import Standard.Base.Data.Array + |from Standard.Base.Data.Boolean import all | |main = | result = System.create_process "PowerShell" (Array.new_2 "-Command" "[System.Console]::Error.WriteLine('err')") "" False False False diff --git a/engine/runtime/src/test/scala/org/enso/std/test/BooleanTest.scala b/engine/runtime/src/test/scala/org/enso/std/test/BooleanTest.scala index 71f9058381f6..b03ab174eda9 100644 --- a/engine/runtime/src/test/scala/org/enso/std/test/BooleanTest.scala +++ b/engine/runtime/src/test/scala/org/enso/std/test/BooleanTest.scala @@ -12,6 +12,7 @@ class BooleanTest extends InterpreterTest { "support if_then_else" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | if True then IO.println "true when true" else IO.println "false when true" @@ -24,6 +25,7 @@ class BooleanTest extends InterpreterTest { "support overriding methods on boolean" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |Boolean.isTrue = this | @@ -40,6 +42,7 @@ class BooleanTest extends InterpreterTest { "support pattern matching" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |to_num b = case b of | True -> 1 @@ -55,6 +58,7 @@ class BooleanTest extends InterpreterTest { "support per-constructor method overloads" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |True.to_num = 1 |False.to_num = 2 @@ -67,6 +71,7 @@ class BooleanTest extends InterpreterTest { "support per-single-constructor method overloads" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |Boolean.to_num = 2 |True.to_num = 1 @@ -79,6 +84,7 @@ class BooleanTest extends InterpreterTest { "support logical AND and OR operators" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | IO.println True&&False @@ -94,6 +100,7 @@ class BooleanTest extends InterpreterTest { "support negation" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | IO.println True.not diff --git a/engine/runtime/src/test/scala/org/enso/std/test/NumberTest.scala b/engine/runtime/src/test/scala/org/enso/std/test/NumberTest.scala index 6887c1c06df5..6743362469c4 100644 --- a/engine/runtime/src/test/scala/org/enso/std/test/NumberTest.scala +++ b/engine/runtime/src/test/scala/org/enso/std/test/NumberTest.scala @@ -11,6 +11,7 @@ class NumberTest extends InterpreterTest { "support equality comparisons" in { val code = """from Standard.Builtins import all + |from Standard.Base import all | |main = | IO.println 7==5 @@ -22,7 +23,7 @@ class NumberTest extends InterpreterTest { "support a recursive sum case" in { val code = - """ + """from Standard.Base import all |main = sumTo -> | summator = acc -> current -> | if current == 0 then acc else summator acc+current current-1