Skip to content

Commit cfbf115

Browse files
committed
Update valid tests
This updates the set of valid tests used in RuntimeValidTests to the very latest set of tests which compile and run.
1 parent 439760a commit cfbf115

23 files changed

+197
-64
lines changed

src/test/java/wyjs/testing/RuntimeValidTests.java

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
import wybs.util.SequentialBuildProject;
4545
import wyc.lang.WhileyFile;
4646
import wyc.task.CompileTask;
47+
import wyc.testing.AllValidTest;
4748
import wyc.util.TestUtils;
49+
import wyc.util.TestUtils.Environment;
4850
import wycc.util.Pair;
4951
import wyfs.lang.Content;
5052
import wyfs.lang.Path;
@@ -88,46 +90,13 @@ public class RuntimeValidTests {
8890
// ===================================================
8991
// WyC problems
9092
// ===================================================
91-
// Normalisation for Method Subtyping
92-
IGNORED.put("Lifetime_Lambda_Valid_2", "#794");
93-
IGNORED.put("Lifetime_Lambda_Valid_5", "#794");
94-
IGNORED.put("Lifetime_Lambda_Valid_6", "#794");
95-
// Support Captured Lifetime Parameters
96-
IGNORED.put("Lifetime_Lambda_Valid_7", "#795");
97-
// Problem Type Checking Union Type
98-
IGNORED.put("RecordSubtype_Valid_1", "#696");
99-
IGNORED.put("RecordSubtype_Valid_2", "#696");
100-
// Function Overloading for Nominal Types
101-
IGNORED.put("Function_Valid_11", "#702");
102-
IGNORED.put("Function_Valid_15", "#702");
103-
// Redesigned Interpreter
104-
IGNORED.put("Lambda_Valid_7", "908");
105-
IGNORED.put("Lambda_Valid_11", "908");
106-
IGNORED.put("Template_Valid_35", "908");
107-
IGNORED.put("Template_Valid_36", "908");
108-
// Bug with Template Inference
109-
IGNORED.put("Template_Valid_38", "912");
110-
// Semantics of Runtime Type Tests
111-
IGNORED.put("RecursiveType_Valid_7", "936");
112-
IGNORED.put("TypeEquals_Valid_61", "936");
113-
IGNORED.put("TypeEquals_Valid_62", "936");
114-
// FlowTyping over Logical Conditions
115-
IGNORED.put("Complex_Valid_3", "936");
116-
IGNORED.put("RecursiveType_Valid_12", "936");
117-
IGNORED.put("RecursiveType_Valid_30", "936");
118-
// Subtype Operator for Casting
119-
IGNORED.put("Coercion_Valid_9", "938");
120-
IGNORED.put("RecordCoercion_Valid_1", "938");
121-
// Unclassified
122-
IGNORED.put("Lifetime_Valid_8", "???");
123-
IGNORED.put("Lifetime_Lambda_Valid_1", "???");
124-
IGNORED.put("Lifetime_Lambda_Valid_3", "???");
125-
IGNORED.put("Lifetime_Lambda_Valid_4", "???");
126-
93+
// Bring over all the currently failing tests for the compiler. There's
94+
// absolutely no point trying to see whether these work or not, since we
95+
// already know they will not.
96+
IGNORED.putAll(AllValidTest.IGNORED);
12797
// ===================================================
12898
// WyJS problems
12999
// ===================================================
130-
131100
// Unbound arithmetic
132101
IGNORED.put("IntOp_Valid_1", "#15");
133102
IGNORED.put("IntConst_Valid_1", "#15");
@@ -207,7 +176,10 @@ public static Pair<Boolean,String> compileWhiley2JavaScript(String whileydir, St
207176
try {
208177
// Construct the project
209178
DirectoryRoot root = new DirectoryRoot(whileydir, registry);
210-
SequentialBuildProject project = new SequentialBuildProject(null, root);
179+
// Construct temporary build environment
180+
Build.Environment environment = new Environment(root,false);
181+
//
182+
SequentialBuildProject project = new SequentialBuildProject(environment, root);
211183
// Identify source files and target files
212184
Pair<Path.Entry<WhileyFile>,Path.Entry<WyilFile>> p = TestUtils.findSourceFiles(root,arg);
213185
List<Path.Entry<WhileyFile>> sources = Arrays.asList(p.first());

tests/valid/Array_Valid_10.whiley

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
type nint is int|null
2+
3+
function update(nint[] current, int mode) -> (nint[] r)
4+
requires |current| > 0:
5+
// Adapted from #950
6+
if current is int[]:
7+
current[0] = null
8+
else:
9+
current[0] = mode
10+
//
11+
return current
12+
13+
public export method test():
14+
assume update([null],123) == [123]
15+
assume update([123],123) == [null]

tests/valid/Assign_Valid_6.whiley

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function update(int|null current, int mode) -> (int|null r):
2+
// Adapted from #950
3+
if current is int:
4+
current = null
5+
else:
6+
current = mode
7+
//
8+
return current
9+
10+
public export method test():
11+
assume update(null,123) == 123
12+
assume update(123,123) == null

tests/valid/DoWhile_Valid_4.whiley

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
2-
31
type Leaf is int
4-
52
type Link is {LinkedList next}
6-
73
type LinkedList is Leaf | Link
84

95
function dist(Link list) -> Leaf:
106
LinkedList iter = list
117
int distance = 0
128
do:
13-
if iter is Link:
14-
iter = iter.next
9+
iter = iter.next
1510
distance = distance + 1
1611
while iter is Link
1712
//

tests/valid/Lambda_Valid_16.whiley

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
type fun_t is function()->int
22

33
function select(int[] items, int i) -> int:
4-
return items[i]
4+
if i >= 0 && i < |items|:
5+
return items[i]
6+
else:
7+
return 0
58

69
public export method test():
710
int[] xs = [11,22,33]
811
fun_t[] fs = [&(->255); 3]
912
//
1013
int i = 0
11-
while i < |xs|:
14+
while i < |xs| where i >= 0 && |xs| == |fs|:
1215
fs[i] = &( -> select(xs,i))
1316
i = i + 1
1417
//

tests/valid/Lambda_Valid_17.whiley

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type fn_t is function(int)->(int,int)
2+
3+
public export method test():
4+
fn_t f = &(int x -> x,x)
5+
int y,z
6+
//
7+
y,z = f(1)
8+
//
9+
assert y == 1
10+
assert z == 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
type State is {
2+
int|null current
3+
}
4+
5+
function update(State s, int mode) -> (State r):
6+
// Adapted from #950
7+
if s.current is int:
8+
s.current = null
9+
else:
10+
s.current = mode
11+
//
12+
return s
13+
14+
public export method test():
15+
assume update({current:null},123).current == 123
16+
assume update({current:123},123).current == null
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
type Open is { int kind, ... }
2+
3+
type State is {
4+
int kind,
5+
int|null current
6+
}
7+
8+
function update(Open s, int mode) -> (Open r):
9+
// Adapted from #950
10+
if s is State:
11+
s.current = mode
12+
//
13+
return s
14+
15+
public export method test():
16+
assume update({kind:2,current:null},123) == {kind:2, current: 123}
17+
assume update({kind:1,current:234},123) == {kind:1, current: 123}
18+
assume update({kind:3},123) == {kind:3}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type Node is {
2+
int nodeType,
3+
...
4+
}
5+
type Element is {
6+
int nodeType,
7+
int nodeValue
8+
}
9+
public export method test():
10+
&Element p_elem = new {nodeType:1, nodeValue:2}
11+
&?Node p_node = p_elem
12+
//
13+
assume p_node->nodeType == 1

tests/valid/Template_Valid_19.whiley

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ function select<S,T>(S|T x, S y) -> (S|T r):
55
return x
66

77
public export method test():
8-
int|bool a1 = 1
9-
int|bool bt = true
10-
bool|int c2 = 2
11-
bool|int df = false
8+
int|bool a1 = (int|bool) 1
9+
int|bool bt = (int|bool) true
10+
bool|int c2 = (bool|int) 2
11+
bool|int df = (bool|int) false
1212
//
1313
assume select(a1,1) == 1
1414
assume select<int,bool>(a1,2) == 1

0 commit comments

Comments
 (0)