Просмотр исходного кода

added a test for definition-side checking with expected failure (#673)

Jeremy G. Siek 4 лет назад
Родитель
Сommit
a1c164f598

+ 1 - 0
executable_semantics/BUILD

@@ -42,6 +42,7 @@ EXAMPLES = [
     "generic_function_apply",
     "generic_function_fail1",
     "generic_function_fail2",
+    "generic_function_fail3",
     "generic_function_swap",
     "generic_function_tuple_map",
     "global_variable1",

+ 11 - 0
executable_semantics/testdata/generic_function_fail3.carbon

@@ -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[T:! Type](x: T) -> T {
+  return x + 0;
+}
+
+fn main() -> Int {
+  return id(0);
+}

+ 4 - 0
executable_semantics/testdata/generic_function_fail3.golden

@@ -0,0 +1,4 @@
+ERROR: 6: type error in addition(1)
+expected: Int
+actual: T
+EXIT CODE: 255