Skip to content

Commit

Permalink
fix brackets in tests after improving toString
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Oct 25, 2024
1 parent 7794eee commit 60fff64
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ public void simpleCheck() throws Exception {

var module = compile(src);
var f1 = findStaticMethod(module, "f");
assertInferredType(f1, "(A -> (B -> C))");
assertInferredType(f1, "A -> (B -> C)");
}

@Test
public void variousExpressions() throws Exception {
final URI uri = new URI("memory://simpleCheck.enso");
final URI uri = new URI("memory://variousExpressions.enso");
final Source src =
Source.newBuilder(
"enso",
"""
type A
Value
+ self other = other
type B
f1 (x : A) -> B = 1
f1 (_ : A) -> B = 1
f2 (x : A) -> B = x + 10
f3 (x : A) -> B = [x]
f4 (x : A) -> B = f1 x
Expand All @@ -64,12 +66,12 @@ public void variousExpressions() throws Exception {
.buildLiteral();

var module = compile(src);
assertInferredType(findStaticMethod(module, "f1"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f2"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f3"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f4"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f5"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f6"), "(A -> B)");
assertInferredType(findStaticMethod(module, "f1"), "A -> B");
assertInferredType(findStaticMethod(module, "f2"), "A -> B");
assertInferredType(findStaticMethod(module, "f3"), "A -> B");
assertInferredType(findStaticMethod(module, "f4"), "A -> B");
assertInferredType(findStaticMethod(module, "f5"), "A -> B");
assertInferredType(findStaticMethod(module, "f6"), "A -> B");
}

@Test
Expand Down Expand Up @@ -108,11 +110,11 @@ public void justArity() throws Exception {
// For a function without ascriptions, we can at least infer the _arity_
// Currently that is denoted by replacing unknowns with Any. Later this may be free type
// variables.
assertInferredType(f4, "(Any -> (Any -> (Any -> (Any -> Any))))");
assertInferredType(f4, "Any -> (Any -> (Any -> (Any -> Any)))");

// For the 'opted-out' ascription, the types are ignored, because they are not checked types.
// But we still infer arity.
assertInferredType(f2, "(Any -> (Any -> Any))");
assertInferredType(f2, "Any -> (Any -> Any)");
}

@Test
Expand All @@ -135,8 +137,8 @@ member_method self (x : A) -> A = x
var staticMethod = findMemberMethod(module, "A", "static_method");
var memberMethod = findMemberMethod(module, "A", "member_method");

assertInferredType(staticMethod, "(A -> A)");
assertInferredType(memberMethod, "(A -> A)");
assertInferredType(staticMethod, "A -> A");
assertInferredType(memberMethod, "A -> A");
}

@Test
Expand All @@ -159,8 +161,8 @@ A.extension_member_method self (x : A) -> A = x
var staticMethod = findMemberMethod(module, "A", "extension_static_method");
var memberMethod = findMemberMethod(module, "A", "extension_member_method");

assertInferredType(staticMethod, "(A -> A)");
assertInferredType(memberMethod, "(A -> A)");
assertInferredType(staticMethod, "A -> A");
assertInferredType(memberMethod, "A -> A");
}

private void assertInferredType(IR ir, String expected) {
Expand Down

0 comments on commit 60fff64

Please sign in to comment.