Reorganize tests into dirs and rename numbered tests (#825)

There's a small update to update_checks.py to handle the recursive directories. Also, I'm only using one level of nesting in this PR but really no reason we can't do more. I'm just not sure what clustering is best right now.

As a pattern, I'm trying to name all failing tests `fail_*.carbon`.
This commit is contained in:
Jon Meow
2021-09-15 16:37:34 -07:00
committed by GitHub
parent 0fec34df03
commit 395a331cde
109 changed files with 72 additions and 93 deletions
@@ -0,0 +1,28 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 3
package ExecutableSemanticsTest api;
// Test access to block-scoped variables upon resuming a continuation.
fn main() -> i32 {
var y: i32 = 0;
__continuation k {
var x: i32 = 0;
x = x + 1;
__await;
x = x + 2;
y = x;
}
__run k;
__run k;
return y;
}
@@ -0,0 +1,32 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 3
package ExecutableSemanticsTest api;
// Test the way in which copying of continuations interacts with data
// on the stack such as the variable `x`. In this example the copy
// happens after the variable `x` is created.
var y: i32 = 0;
fn main() -> i32 {
__continuation k1 {
var x: i32 = 0;
x = x + 1;
__await;
x = x + 2;
y = x;
}
__run k1;
var k2: __Continuation = k1;
__run k2;
return y;
}
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 0
package ExecutableSemanticsTest api;
// Test that creating a continuation doesn't do anything.
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
}
return x;
}
@@ -0,0 +1,30 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: not executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: not executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: RUNTIME ERROR: {{.*}}/executable_semantics/testdata/experimental_continuation/fail_lifetime.carbon:21: undefined behavior: access to dead value 1
package ExecutableSemanticsTest api;
// Test that the read from x triggers an error because x is dead.
// This test also demonstrates how by-reference free-variable capture
// is dangerous and can happen inside continuations.
fn capture() -> __Continuation {
var x: i32 = 1;
__continuation k {
var y: i32 = x;
}
return k;
}
fn main() -> i32 {
var k: __Continuation = capture();
__run k; // error, lifetime of x is over
return 0;
}
@@ -0,0 +1,42 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 10
package ExecutableSemanticsTest api;
// Test recursive functions inside continuations.
var current: i32 = 0;
fn CountUpTo(x: i32) -> i32 {
if (x == 0) {
current = 0;
__await;
return 0;
} else {
current = 1 + CountUpTo(x - 1);
__await;
return current;
}
}
fn main() -> i32 {
__continuation k {
CountUpTo(5);
}
var sum: i32 = 0;
var count: i32 = 5;
while (not (count == 0)) {
__run k;
sum = sum + current;
count = count - 1;
}
return sum;
}
@@ -0,0 +1,23 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 1
package ExecutableSemanticsTest api;
// Test creating and running a continuation.
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
}
__run k;
return x;
}
@@ -0,0 +1,27 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 3
package ExecutableSemanticsTest api;
// Test pausing a continuation with `__await` and restarting it with
// `__run`.
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
__await;
x = x + 2;
}
__run k;
__run k;
return x;
}
@@ -0,0 +1,28 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: executable_semantics %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
// RUN: executable_semantics --trace %s 2>&1 | \
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: executable_semantics %s
// CHECK: result: 3
package ExecutableSemanticsTest api;
// Assignment for continuations is shallow, so `k2` refers to the same
// continuation as `k1`.
fn main() -> i32 {
var x: i32 = 0;
__continuation k1 {
x = x + 1;
__await;
x = x + 2;
}
var k2: __Continuation = k1;
__run k1;
__run k2;
return x;
}