Skip to content

Commit

Permalink
Renamed the tests to be more descriptive.
Browse files Browse the repository at this point in the history
  • Loading branch information
V0ldek committed May 9, 2020
1 parent df677f1 commit d72bb6f
Show file tree
Hide file tree
Showing 236 changed files with 283 additions and 88 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
iterate :: Iterator Integer;
iterate = {
yield return;
};

main :: Integer;
main = iterate.current;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
iterate :: RefIterator Integer sideeffect;
iterate = {
eval printLn "Empty." ();
yield return;
};

main :: sideeffect -> Integer;
main = iterate.current ();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error: iterator's `current` function called before `next` or the sequence had no elements.

Execution terminated with an error: runtime error.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error: iterator's `current` function called before `next` or the sequence had no elements.

Execution terminated with an error: runtime error.
12 changes: 12 additions & 0 deletions test/Harper/Tests/Bad/CallingCurrentOnAnRefIteratorBeforeNext.har
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
iterate :: RefIterator Integer sideeffect;
iterate = {
var (i :: Integer) = 0;
while true {
yield i;
eval printLn i ();
i += 1;
}
};

main :: sideeffect -> Integer;
main = iterate.current ();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error: iterator's `current` function called before `next` or the sequence had no elements.

Execution terminated with an error: runtime error.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
value List a = {
variant Empty = { };
};

value Bag a b c d = {
variant Empty = { };
variant Bag = {
data = {
a :: a; a :: b; c :: c; c :: d;
}
};
};


main :: Integer;
main = 42;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Error: conflicting type variant names `Empty`.
Conflicting declarations:
value List a = {
variant Empty = {
} ;
}

Located at line 1 column 1
value Bag a b c d = {
variant Empty = {
} ;
variant Bag = {
data = {
a :: a ;
a :: b ;
c :: c ;
c :: d ;
}
} ;
}

Located at line 5 column 1


Execution terminated with an error: type error.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ value List a = {

value Bag a b c d = {
variant Empty = { };
variant Bag = {
variant NonEmpty = {
data = {
a :: a; a :: b; c :: c; c :: d;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error: conflicting type variant names `Empty`, `NonEmpty`.
Error: conflicting type variant names `Empty`, `NonEmpty`, `NonEmpty`.
Conflicting declarations:
value List a = {
variant Empty = {
Expand All @@ -20,7 +20,7 @@ Located at line 1 column 1
value Bag a b c d = {
variant Empty = {
} ;
variant Bag = {
variant NonEmpty = {
data = {
a :: a ;
a :: b ;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
value List a = {
variant Empty = { };

variant NonEmpty = {
data = {
head :: a;
}
};

variant NonEmpty = {
data = {
head :: a;
tail :: List a;
}
};
};

value Bag a b c d = {
variant Bag = {
data = {
a :: a; a :: b; c :: c; c :: d;
}
};
};


main :: Integer;
main = 42;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Error: conflicting type variant names `NonEmpty`.
Conflicting declarations:
value List a = {
variant Empty = {
} ;
variant NonEmpty = {
data = {
head :: a ;
}
} ;
variant NonEmpty = {
data = {
head :: a ;
tail :: List a ;
}
} ;
}

Located at line 1 column 1


Execution terminated with an error: type error.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
main :: sideeffect -> ();
main = {
// If lambdas could be recursive, i.e. `f` was visible in the body of the deconstructed lambda,
// this code would have no sensible semantics, as `f` would be used during the evaluation
// of the value being assigned to it. This restriction could theoretically be dropped if the rhs is pure.
(f :: Integer -> Integer) = (\(x :: Integer) => {
eval printLn (f 10) ();
return (\(n :: Integer) => n * x);
}) 42 ();

eval printLn (f 10) ();
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Error: undeclared identifier `f`.
During evaluation of:
f
Located at line 4 column 21
Located at line 7 column 21

Execution terminated with an error: type error.
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
f :: Integer -> Integer;
f n = {
var (x :: Integer);

var (result :: Integer) = 0;

if (n == 42) {
x := n;

// x is definitely assigned.

result += x;
}
else {
x := 0;
}

// x is not definitely assigned.

(result :: Integer) = x + n;
result += x + n;
return result;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Error: variable `x` is not definitely assigned at point of use.
During evaluation of:
x
Located at line 4 column 10
Located at line 16 column 13

Execution terminated with an error: type error.
28 changes: 28 additions & 0 deletions test/Harper/Tests/Bad/DefiniteAssignment_IfElseIf.har
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
f :: Integer -> Integer;
f n = {
var (x :: Integer);
var (result :: Integer) = 0;

if (n == 42) {
x := n;

// x is definitey assigned.

result += x;
}
else if (n < 42) {
x := 0;

// x is definitely assigned.

result += x;
}

// x is not definitely assigned.

result += x + n;
return result;
};

main :: Integer;
main = f 42;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Error: variable `x` is not definitely assigned at point of use.
During evaluation of:
x
Located at line 12 column 25
Located at line 23 column 13

Execution terminated with an error: type error.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ g b = {
h :: a -> b;
h = {
match f g {
// Object being matched is of type Bool -> Integer. Generalization to c -> d should fail.
(y :: c -> d) => return y;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Error: the pattern of type `c& -> d&` cannot be used to match an expression of t
During evaluation of:
(y :: c -> d)=> return y ;

Located at line 15 column 5
Located at line 16 column 5


Execution terminated with an error: type error.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions test/Harper/Tests/Bad/NonBoolPredicate_While.har
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
f :: Integer -> Integer;
f n = {
while 1 {
return n;
}
return 0;
};

main :: Integer;
main = f 42;
9 changes: 9 additions & 0 deletions test/Harper/Tests/Bad/NonBoolPredicate_While.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Error: expression `1` of type `Integer` cannot be used as a predicate in a conditional.
During evaluation of:
while 1 {
return n ;
}

Located at line 3 column 3

Execution terminated with an error: type error.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions test/Harper/Tests/Bad/issue016_definiteAssignment.har

This file was deleted.

14 changes: 0 additions & 14 deletions test/Harper/Tests/Bad/issue016_ifDefiniteAssignment.har

This file was deleted.

6 changes: 0 additions & 6 deletions test/Harper/Tests/Bad/issue016_ifDefiniteAssignment.out

This file was deleted.

17 changes: 0 additions & 17 deletions test/Harper/Tests/Bad/issue016_ifElseIfDefiniteAssignment.har

This file was deleted.

9 changes: 0 additions & 9 deletions test/Harper/Tests/Bad/issue019_lambdaSE2.har

This file was deleted.

File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions test/Harper/Tests/Good/BooleanOperators_LazyAnd.har
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fun :: Integer -> Bool;
fun n = fun (n + 1);

main :: Bool;
main = false and (fun 42);
1 change: 1 addition & 0 deletions test/Harper/Tests/Good/BooleanOperators_LazyAnd.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Execution ended with value: false
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d72bb6f

Please sign in to comment.