mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:11:04 +01:00
Type computation tests (#511)
* test of a little type computation * another test and some bug fixes
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
8: type error in pattern variable
|
||||
expected: (x = Int@2, y = Int@3)
|
||||
actual: (y = Int@0, x = Int@1)
|
||||
expected: (x = Int, y = Int)
|
||||
actual: (y = Int, x = Int)
|
||||
EXIT CODE: 255
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
8: type error in ==
|
||||
expected: (0 = Int@2, 1 = Int@3)
|
||||
actual: (0 = Int@5)
|
||||
expected: (0 = Int, 1 = Int)
|
||||
actual: (0 = Int)
|
||||
EXIT CODE: 255
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// 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
|
||||
|
||||
fn Id(Type: t) => t;
|
||||
|
||||
// Test non-trivial type expression in variable declaration statement.
|
||||
|
||||
fn main() -> Int {
|
||||
var Id(Int): x = 0;
|
||||
return x;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
result: 0
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// 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
|
||||
|
||||
fn Id(Type: t) => t;
|
||||
|
||||
// Test non-trivial type expression in return type.
|
||||
|
||||
fn main() -> Id(Int) {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
result: 0
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// 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
|
||||
|
||||
fn Id(Type: t) => t;
|
||||
|
||||
// Test non-trivial type expression in parameter type.
|
||||
|
||||
fn f(Id(Int): x) -> Int {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn main() -> Int {
|
||||
return f(0);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
result: 0
|
||||
Reference in New Issue
Block a user