diff --git a/executable_semantics/ast/BUILD b/executable_semantics/ast/BUILD index 5dbec58e75a2..fc08eab60345 100644 --- a/executable_semantics/ast/BUILD +++ b/executable_semantics/ast/BUILD @@ -4,6 +4,15 @@ package(default_visibility = ["//executable_semantics:__subpackages__"]) +cc_library( + name = "ast", + hdrs = ["ast.h"], + deps = [ + ":declaration", + ":library_name", + ], +) + cc_library( name = "class_definition", hdrs = ["class_definition.h"], @@ -19,7 +28,6 @@ cc_library( name = "declaration", srcs = ["declaration.cpp"], hdrs = [ - "abstract_syntax_tree.h", "declaration.h", ], deps = [ @@ -82,6 +90,11 @@ cc_library( ], ) +cc_library( + name = "library_name", + hdrs = ["library_name.h"], +) + cc_library( name = "paren_contents", hdrs = ["paren_contents.h"], diff --git a/executable_semantics/ast/abstract_syntax_tree.h b/executable_semantics/ast/abstract_syntax_tree.h deleted file mode 100644 index 655912ef21c2..000000000000 --- a/executable_semantics/ast/abstract_syntax_tree.h +++ /dev/null @@ -1,17 +0,0 @@ -// 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 - -#ifndef EXECUTABLE_SEMANTICS_AST_ABSTRACT_SYNTAX_TREE_H_ -#define EXECUTABLE_SEMANTICS_AST_ABSTRACT_SYNTAX_TREE_H_ - -#include - -#include "executable_semantics/ast/declaration.h" -#include "executable_semantics/common/ptr.h" - -namespace Carbon { -using AST = std::list>; -} - -#endif // EXECUTABLE_SEMANTICS_AST_ABSTRACT_SYNTAX_TREE_H_ diff --git a/executable_semantics/ast/ast.h b/executable_semantics/ast/ast.h new file mode 100644 index 000000000000..646c863f64e0 --- /dev/null +++ b/executable_semantics/ast/ast.h @@ -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 + +#ifndef EXECUTABLE_SEMANTICS_AST_AST_H_ +#define EXECUTABLE_SEMANTICS_AST_AST_H_ + +#include + +#include "executable_semantics/ast/declaration.h" +#include "executable_semantics/ast/library_name.h" +#include "executable_semantics/common/ptr.h" + +namespace Carbon { + +// A Carbon file's AST. +struct AST { + // The package directive's library. + LibraryName package; + // The package directive's API or impl state. + bool is_api; + // Import directives. + std::vector imports; + // The file's ordered declarations. + std::list> declarations; +}; + +} // namespace Carbon + +#endif // EXECUTABLE_SEMANTICS_AST_AST_H_ diff --git a/executable_semantics/ast/library_name.h b/executable_semantics/ast/library_name.h new file mode 100644 index 000000000000..31c1249147d4 --- /dev/null +++ b/executable_semantics/ast/library_name.h @@ -0,0 +1,25 @@ +// 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 + +#ifndef EXECUTABLE_SEMANTICS_AST_LIBRARY_NAME_H_ +#define EXECUTABLE_SEMANTICS_AST_LIBRARY_NAME_H_ + +#include + +namespace Carbon { + +// Identifies a particular library. For example, "Geometry//Objects/FourSides" +// will have package="Geometry" and path="Objects/FourSides". +struct LibraryName { + // The library's package. + std::string package; + + // The package-relative path of the library. This defaults to the empty + // string. + std::string path; +}; + +} // namespace Carbon + +#endif // EXECUTABLE_SEMANTICS_AST_LIBRARY_NAME_H_ diff --git a/executable_semantics/interpreter/BUILD b/executable_semantics/interpreter/BUILD index 03dcb009f90a..7f15042c46c7 100644 --- a/executable_semantics/interpreter/BUILD +++ b/executable_semantics/interpreter/BUILD @@ -43,6 +43,7 @@ cc_library( deps = [ ":interpreter", ":type_checker", + "//executable_semantics/ast", ], ) diff --git a/executable_semantics/interpreter/exec_program.cpp b/executable_semantics/interpreter/exec_program.cpp index d2d560ea95b7..e1afcde17547 100644 --- a/executable_semantics/interpreter/exec_program.cpp +++ b/executable_semantics/interpreter/exec_program.cpp @@ -15,7 +15,7 @@ namespace Carbon { // Adds builtins, currently only Print(). Note Print() is experimental, not // standardized, but is made available for printing state in tests. -static void AddIntrinsics(std::list>* fs) { +static void AddIntrinsics(std::list>* declarations) { SourceLocation loc("", 0); std::vector print_fields = {TuplePattern::Field( "0", global_arena->New( @@ -34,24 +34,24 @@ static void AddIntrinsics(std::list>* fs) { global_arena->New( global_arena->New(loc)), /*is_omitted_return_type=*/false, print_return)); - fs->insert(fs->begin(), print); + declarations->insert(declarations->begin(), print); } -void ExecProgram(std::list> fs) { - AddIntrinsics(&fs); +void ExecProgram(AST ast) { + AddIntrinsics(&ast.declarations); if (tracing_output) { llvm::outs() << "********** source program **********\n"; - for (const auto decl : fs) { + for (const auto decl : ast.declarations) { llvm::outs() << *decl; } llvm::outs() << "********** type checking **********\n"; } TypeChecker type_checker; - TypeChecker::TypeCheckContext p = type_checker.TopLevel(fs); + TypeChecker::TypeCheckContext p = type_checker.TopLevel(ast.declarations); TypeEnv top = p.types; Env ct_top = p.values; std::list> new_decls; - for (const auto decl : fs) { + for (const auto decl : ast.declarations) { new_decls.push_back(type_checker.MakeTypeChecked(decl, top, ct_top)); } if (tracing_output) { diff --git a/executable_semantics/interpreter/exec_program.h b/executable_semantics/interpreter/exec_program.h index be819b835e7f..c4f42781ea45 100644 --- a/executable_semantics/interpreter/exec_program.h +++ b/executable_semantics/interpreter/exec_program.h @@ -11,13 +11,12 @@ #include -#include "executable_semantics/ast/declaration.h" -#include "executable_semantics/common/ptr.h" +#include "executable_semantics/ast/ast.h" namespace Carbon { // Runs the top-level declaration list. -void ExecProgram(std::list> fs); +void ExecProgram(AST ast); } // namespace Carbon diff --git a/executable_semantics/syntax/BUILD b/executable_semantics/syntax/BUILD index ba243ecd156b..dfc58f3668fd 100644 --- a/executable_semantics/syntax/BUILD +++ b/executable_semantics/syntax/BUILD @@ -37,6 +37,7 @@ cc_library( "//common:check", "//common:ostream", "//common:string_helpers", + "//executable_semantics/ast", "//executable_semantics/ast:declaration", "//executable_semantics/ast:expression", "//executable_semantics/ast:paren_contents", diff --git a/executable_semantics/syntax/lexer.lpp b/executable_semantics/syntax/lexer.lpp index 3c076477c3bf..d9f446684ece 100644 --- a/executable_semantics/syntax/lexer.lpp +++ b/executable_semantics/syntax/lexer.lpp @@ -30,6 +30,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception /* Table begin. */ AND "and" +API "api" ARROW "->" AUTO "auto" AWAIT "__await" @@ -53,13 +54,17 @@ FALSE "false" FN "fn" FNTY "fnty" IF "if" +IMPL "impl" +IMPORT "import" LEFT_CURLY_BRACE "{" LEFT_PARENTHESIS "(" LEFT_SQUARE_BRACKET "[" +LIBRARY "library" MATCH "match" MINUS "-" NOT "not" OR "or" +PACKAGE "package" PERIOD "." PLUS "+" RETURN "return" @@ -119,6 +124,7 @@ string_literal \"([^\\\"\n\v\f\r]|\\.)*\" /* Table begin. */ {AND} { return SIMPLE_TOKEN(AND); } +{API} { return SIMPLE_TOKEN(API); } {ARROW} { return SIMPLE_TOKEN(ARROW); } {AUTO} { return SIMPLE_TOKEN(AUTO); } {AWAIT} { return SIMPLE_TOKEN(AWAIT); } @@ -142,13 +148,17 @@ string_literal \"([^\\\"\n\v\f\r]|\\.)*\" {FNTY} { return SIMPLE_TOKEN(FNTY); } {FN} { return SIMPLE_TOKEN(FN); } {IF} { return SIMPLE_TOKEN(IF); } +{IMPL} { return SIMPLE_TOKEN(IMPL); } +{IMPORT} { return SIMPLE_TOKEN(IMPORT); } {LEFT_PARENTHESIS} { return SIMPLE_TOKEN(LEFT_PARENTHESIS); } {LEFT_CURLY_BRACE} { return SIMPLE_TOKEN(LEFT_CURLY_BRACE); } {LEFT_SQUARE_BRACKET} { return SIMPLE_TOKEN(LEFT_SQUARE_BRACKET); } +{LIBRARY} { return SIMPLE_TOKEN(LIBRARY); } {MATCH} { return SIMPLE_TOKEN(MATCH); } {MINUS} { return SIMPLE_TOKEN(MINUS); } {NOT} { return SIMPLE_TOKEN(NOT); } {OR} { return SIMPLE_TOKEN(OR); } +{PACKAGE} { return SIMPLE_TOKEN(PACKAGE); } {PERIOD} { return SIMPLE_TOKEN(PERIOD); } {PLUS} { return SIMPLE_TOKEN(PLUS); } {RETURN} { return SIMPLE_TOKEN(RETURN); } diff --git a/executable_semantics/syntax/parse.h b/executable_semantics/syntax/parse.h index 19e9edde257b..2d9ba6141093 100644 --- a/executable_semantics/syntax/parse.h +++ b/executable_semantics/syntax/parse.h @@ -8,7 +8,7 @@ #include #include -#include "executable_semantics/ast/abstract_syntax_tree.h" +#include "executable_semantics/ast/ast.h" namespace Carbon { diff --git a/executable_semantics/syntax/parse_and_lex_context.h b/executable_semantics/syntax/parse_and_lex_context.h index 46616b04bc50..1d1d1fb75b8e 100644 --- a/executable_semantics/syntax/parse_and_lex_context.h +++ b/executable_semantics/syntax/parse_and_lex_context.h @@ -7,7 +7,7 @@ #include -#include "executable_semantics/ast/abstract_syntax_tree.h" +#include "executable_semantics/ast/ast.h" #include "executable_semantics/syntax/parser.h" // from parser.ypp namespace Carbon { diff --git a/executable_semantics/syntax/parser.ypp b/executable_semantics/syntax/parser.ypp index 51de0c267b5b..93f012e4cfd4 100644 --- a/executable_semantics/syntax/parser.ypp +++ b/executable_semantics/syntax/parser.ypp @@ -65,7 +65,7 @@ %code requires { #include - #include "executable_semantics/ast/abstract_syntax_tree.h" + #include "executable_semantics/ast/ast.h" #include "executable_semantics/ast/declaration.h" #include "executable_semantics/ast/expression.h" #include "executable_semantics/ast/function_definition.h" @@ -93,6 +93,11 @@ %token sized_type_literal %token string_literal %type designator +%type > package_directive +%type import_directive +%type > import_directives +%type optional_library_path +%type api_or_impl %type >> declaration %type >> function_declaration %type >> function_definition @@ -133,6 +138,7 @@ %token // Most tokens have their spelling defined in lexer.lpp. AND + API ARROW AUTO AWAIT @@ -156,13 +162,17 @@ FN FNTY IF + IMPL + IMPORT LEFT_CURLY_BRACE LEFT_PARENTHESIS LEFT_SQUARE_BRACKET + LIBRARY MATCH MINUS NOT OR + PACKAGE PERIOD PLUS RETURN @@ -217,8 +227,42 @@ %start input %% -input: declaration_list - { parsed_program = $1; } +input: package_directive import_directives declaration_list + { + parsed_program = AST({.package = $1.first, + .is_api = $1.second, + .imports = std::move($2), + .declarations = std::move($3)}); + } +; +package_directive: + PACKAGE identifier optional_library_path api_or_impl SEMICOLON + { $$ = {LibraryName({.package = $2, .path = $3}), $4}; } +; +import_directive: + IMPORT identifier optional_library_path SEMICOLON + { $$ = LibraryName({.package = $2, .path = $3}); } +; +import_directives: + // Empty + { $$ = std::vector(); } +| import_directives import_directive + { + $$ = std::move($1); + $$.push_back($2); + } +; +optional_library_path: + // Empty + { $$ = ""; } +| LIBRARY string_literal + { $$ = $2; } +; +api_or_impl: + API + { $$ = true; } +| IMPL + { $$ = false; } ; expression: identifier diff --git a/executable_semantics/test_list.bzl b/executable_semantics/test_list.bzl index 5a8711cd3580..038ad64bc5a4 100644 --- a/executable_semantics/test_list.bzl +++ b/executable_semantics/test_list.bzl @@ -61,6 +61,9 @@ TEST_LIST = [ "if_nesting", "if_true", "ignored_parameter", + "import_late", + "import_nonexistent_library", + "import_nonexistent_package", "invalid_char", "match_any_int", "match_int", @@ -68,6 +71,8 @@ TEST_LIST = [ "match_placeholder", "next", "no_match", + "package_library", + "package_missing", "pattern_init", "pattern_variable_fail", "placeholder_variable", diff --git a/executable_semantics/testdata/assignment_copy1.carbon b/executable_semantics/testdata/assignment_copy1.carbon index 5b8e663d0bc7..2ce230b44d70 100644 --- a/executable_semantics/testdata/assignment_copy1.carbon +++ b/executable_semantics/testdata/assignment_copy1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test that assignment performs a copy and does not create an alias. fn main() -> i32 { diff --git a/executable_semantics/testdata/assignment_copy2.carbon b/executable_semantics/testdata/assignment_copy2.carbon index 6507d38a4718..ea47574404db 100644 --- a/executable_semantics/testdata/assignment_copy2.carbon +++ b/executable_semantics/testdata/assignment_copy2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test that assignment performs a copy and does not create an alias. fn main() -> i32 { diff --git a/executable_semantics/testdata/block1.carbon b/executable_semantics/testdata/block1.carbon index 83cd1cfb24b3..27014dc98af4 100644 --- a/executable_semantics/testdata/block1.carbon +++ b/executable_semantics/testdata/block1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: i32 = 0; { diff --git a/executable_semantics/testdata/block2.carbon b/executable_semantics/testdata/block2.carbon index 4e8f3c181998..b3651b091dd9 100644 --- a/executable_semantics/testdata/block2.carbon +++ b/executable_semantics/testdata/block2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: i32 = 0; { diff --git a/executable_semantics/testdata/break1.carbon b/executable_semantics/testdata/break1.carbon index fbb844887bd4..419179e1146e 100644 --- a/executable_semantics/testdata/break1.carbon +++ b/executable_semantics/testdata/break1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: i32 = 2; while (true) { diff --git a/executable_semantics/testdata/choice1.carbon b/executable_semantics/testdata/choice1.carbon index 0ea54952e6d0..ca12a8a1b47a 100644 --- a/executable_semantics/testdata/choice1.carbon +++ b/executable_semantics/testdata/choice1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + choice Ints { None, One(i32), diff --git a/executable_semantics/testdata/class1.carbon b/executable_semantics/testdata/class1.carbon index b893bb6faa4b..86ca039a0436 100644 --- a/executable_semantics/testdata/class1.carbon +++ b/executable_semantics/testdata/class1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class2.carbon b/executable_semantics/testdata/class2.carbon index e36a85053bc3..838a9c65b978 100644 --- a/executable_semantics/testdata/class2.carbon +++ b/executable_semantics/testdata/class2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class3.carbon b/executable_semantics/testdata/class3.carbon index 17b6d8e1b10a..bf5a8ae7ba8c 100644 --- a/executable_semantics/testdata/class3.carbon +++ b/executable_semantics/testdata/class3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class_field_access_mismatch.carbon b/executable_semantics/testdata/class_field_access_mismatch.carbon index 547a629a084b..5283b9a2fdfc 100644 --- a/executable_semantics/testdata/class_field_access_mismatch.carbon +++ b/executable_semantics/testdata/class_field_access_mismatch.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class_field_access_mismatch.golden b/executable_semantics/testdata/class_field_access_mismatch.golden index 30a5f60a5b24..4e96bed3d862 100644 --- a/executable_semantics/testdata/class_field_access_mismatch.golden +++ b/executable_semantics/testdata/class_field_access_mismatch.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/class_field_access_mismatch.carbon:11: class Point does not have a field named z +COMPILATION ERROR: executable_semantics/testdata/class_field_access_mismatch.carbon:13: class Point does not have a field named z EXIT CODE: 255 diff --git a/executable_semantics/testdata/class_field_mismatch.carbon b/executable_semantics/testdata/class_field_mismatch.carbon index 24126bfb0aef..c8dc5930163b 100644 --- a/executable_semantics/testdata/class_field_mismatch.carbon +++ b/executable_semantics/testdata/class_field_mismatch.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class_field_mismatch.golden b/executable_semantics/testdata/class_field_mismatch.golden index 188dd1f33297..66e557f97660 100644 --- a/executable_semantics/testdata/class_field_mismatch.golden +++ b/executable_semantics/testdata/class_field_mismatch.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/class_field_mismatch.carbon:11: type error in call +COMPILATION ERROR: executable_semantics/testdata/class_field_mismatch.carbon:13: type error in call expected: (x = i32, y = i32) actual: (x = i32, z = i32) EXIT CODE: 255 diff --git a/executable_semantics/testdata/class_field_missing.carbon b/executable_semantics/testdata/class_field_missing.carbon index efe61f07294b..3fc71fc0b61f 100644 --- a/executable_semantics/testdata/class_field_missing.carbon +++ b/executable_semantics/testdata/class_field_missing.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + class Point { var x: i32; var y: i32; diff --git a/executable_semantics/testdata/class_field_missing.golden b/executable_semantics/testdata/class_field_missing.golden index cf1731d6af4a..ab9861632476 100644 --- a/executable_semantics/testdata/class_field_missing.golden +++ b/executable_semantics/testdata/class_field_missing.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/class_field_missing.carbon:11: type error in call +COMPILATION ERROR: executable_semantics/testdata/class_field_missing.carbon:13: type error in call expected: (x = i32, y = i32) actual: (x = i32) EXIT CODE: 255 diff --git a/executable_semantics/testdata/continue1.carbon b/executable_semantics/testdata/continue1.carbon index bca3143537b6..75f6611d232b 100644 --- a/executable_semantics/testdata/continue1.carbon +++ b/executable_semantics/testdata/continue1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: auto = 2; while (not (x == 0)) { diff --git a/executable_semantics/testdata/experimental_continuation1.carbon b/executable_semantics/testdata/experimental_continuation1.carbon index 003467591f6a..179814c5d3a5 100644 --- a/executable_semantics/testdata/experimental_continuation1.carbon +++ b/executable_semantics/testdata/experimental_continuation1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test that creating a continuation doesn't do anything. fn main() -> i32 { diff --git a/executable_semantics/testdata/experimental_continuation2.carbon b/executable_semantics/testdata/experimental_continuation2.carbon index c60f9341af99..a1a15302ad82 100644 --- a/executable_semantics/testdata/experimental_continuation2.carbon +++ b/executable_semantics/testdata/experimental_continuation2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test creating and running a continuation. fn main() -> i32 { diff --git a/executable_semantics/testdata/experimental_continuation3.carbon b/executable_semantics/testdata/experimental_continuation3.carbon index e11178f20df8..8d9483681da0 100644 --- a/executable_semantics/testdata/experimental_continuation3.carbon +++ b/executable_semantics/testdata/experimental_continuation3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test pausing a continuation with `__await` and restarting it with // `__run`. diff --git a/executable_semantics/testdata/experimental_continuation4.carbon b/executable_semantics/testdata/experimental_continuation4.carbon index 6f0ce7d51b8e..78baab3cfa4c 100644 --- a/executable_semantics/testdata/experimental_continuation4.carbon +++ b/executable_semantics/testdata/experimental_continuation4.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Assignment for continuations is shallow, so `k2` refers to the same // continuation as `k1`. diff --git a/executable_semantics/testdata/experimental_continuation5.carbon b/executable_semantics/testdata/experimental_continuation5.carbon index 02c826ce827e..07f24745d00b 100644 --- a/executable_semantics/testdata/experimental_continuation5.carbon +++ b/executable_semantics/testdata/experimental_continuation5.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test access to block-scoped variables upon resuming a continuation. fn main() -> i32 { diff --git a/executable_semantics/testdata/experimental_continuation6.carbon b/executable_semantics/testdata/experimental_continuation6.carbon index e31592c94d15..ecd0b5a9b4fd 100644 --- a/executable_semantics/testdata/experimental_continuation6.carbon +++ b/executable_semantics/testdata/experimental_continuation6.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test recursive functions inside continuations. var current: i32 = 0; diff --git a/executable_semantics/testdata/experimental_continuation7.carbon b/executable_semantics/testdata/experimental_continuation7.carbon index 9ada4c5a5cb9..4c79aecf68ea 100644 --- a/executable_semantics/testdata/experimental_continuation7.carbon +++ b/executable_semantics/testdata/experimental_continuation7.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +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. diff --git a/executable_semantics/testdata/experimental_continuation8.carbon b/executable_semantics/testdata/experimental_continuation8.carbon index d37bfe9b5e15..aad639c2fe62 100644 --- a/executable_semantics/testdata/experimental_continuation8.carbon +++ b/executable_semantics/testdata/experimental_continuation8.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +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 before the variable `x` is created, so each continuation diff --git a/executable_semantics/testdata/experimental_continuation9.carbon b/executable_semantics/testdata/experimental_continuation9.carbon index 5cbba38d43f1..ab1c6ec35356 100644 --- a/executable_semantics/testdata/experimental_continuation9.carbon +++ b/executable_semantics/testdata/experimental_continuation9.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +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. diff --git a/executable_semantics/testdata/experimental_continuation9.golden b/executable_semantics/testdata/experimental_continuation9.golden index c5c9dcf99c2f..6997e4f3914f 100644 --- a/executable_semantics/testdata/experimental_continuation9.golden +++ b/executable_semantics/testdata/experimental_continuation9.golden @@ -1,2 +1,2 @@ -RUNTIME ERROR: executable_semantics/testdata/experimental_continuation9.carbon:12: undefined behavior: access to dead value 1 +RUNTIME ERROR: executable_semantics/testdata/experimental_continuation9.carbon:14: undefined behavior: access to dead value 1 EXIT CODE: 255 diff --git a/executable_semantics/testdata/fun1.carbon b/executable_semantics/testdata/fun1.carbon index c9b53d8891ab..3fbbc11df351 100644 --- a/executable_semantics/testdata/fun1.carbon +++ b/executable_semantics/testdata/fun1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn f(x: i32) -> i32 { return x - 1; } diff --git a/executable_semantics/testdata/fun2.carbon b/executable_semantics/testdata/fun2.carbon index f89949c2dd0c..14d05e157256 100644 --- a/executable_semantics/testdata/fun2.carbon +++ b/executable_semantics/testdata/fun2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // This tests the call-by-value aspect of parameter passing. // This makes sure that when the value in `x` dies, // it does not cause the value in `a` to also die. diff --git a/executable_semantics/testdata/fun3.carbon b/executable_semantics/testdata/fun3.carbon index e8997e87c3c4..9fa23b4eb8ca 100644 --- a/executable_semantics/testdata/fun3.carbon +++ b/executable_semantics/testdata/fun3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test multiple arguments fn f(x: i32, y: i32) -> i32 { return x + y; diff --git a/executable_semantics/testdata/fun4.carbon b/executable_semantics/testdata/fun4.carbon index 9e38cd98dbdc..332c84240b74 100644 --- a/executable_semantics/testdata/fun4.carbon +++ b/executable_semantics/testdata/fun4.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test empty parameters and return type fn f() { } diff --git a/executable_semantics/testdata/fun5.carbon b/executable_semantics/testdata/fun5.carbon index 1f392b660683..eced169d666e 100644 --- a/executable_semantics/testdata/fun5.carbon +++ b/executable_semantics/testdata/fun5.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn add(x: i32, y: i32) => x + y; fn main() -> i32 { diff --git a/executable_semantics/testdata/fun6_fail_type.carbon b/executable_semantics/testdata/fun6_fail_type.carbon index 1576f5fb3c04..22123ee50a71 100644 --- a/executable_semantics/testdata/fun6_fail_type.carbon +++ b/executable_semantics/testdata/fun6_fail_type.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn f(x: i32, y: i32) -> i32 { return x + y; } fn main() -> i32 { diff --git a/executable_semantics/testdata/fun6_fail_type.golden b/executable_semantics/testdata/fun6_fail_type.golden index 9e826ffdfe26..aa9005864c60 100644 --- a/executable_semantics/testdata/fun6_fail_type.golden +++ b/executable_semantics/testdata/fun6_fail_type.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/fun6_fail_type.carbon:10: type error in call +COMPILATION ERROR: executable_semantics/testdata/fun6_fail_type.carbon:12: type error in call expected: (0 = i32, 1 = i32) actual: (0 = (0 = i32, 1 = i32)) EXIT CODE: 255 diff --git a/executable_semantics/testdata/fun_named_params.carbon b/executable_semantics/testdata/fun_named_params.carbon index f9b627c987c2..f325ddff6eab 100644 --- a/executable_semantics/testdata/fun_named_params.carbon +++ b/executable_semantics/testdata/fun_named_params.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn f(x: i32, .d = y: i32) => x + y; fn main() -> i32 { diff --git a/executable_semantics/testdata/fun_named_params2.carbon b/executable_semantics/testdata/fun_named_params2.carbon index fe4911e62728..41b37a43b01b 100644 --- a/executable_semantics/testdata/fun_named_params2.carbon +++ b/executable_semantics/testdata/fun_named_params2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn f(x: i32, .d = y: i32, z: i32, .e = a: i32) => (x + y) - (z + a); fn main() -> i32 { diff --git a/executable_semantics/testdata/fun_named_params2.golden b/executable_semantics/testdata/fun_named_params2.golden index 5c2e78c66a66..880c91ad4bc4 100644 --- a/executable_semantics/testdata/fun_named_params2.golden +++ b/executable_semantics/testdata/fun_named_params2.golden @@ -1,2 +1,2 @@ -PROGRAM ERROR: executable_semantics/testdata/fun_named_params2.carbon:5: positional members must come before named members +PROGRAM ERROR: executable_semantics/testdata/fun_named_params2.carbon:7: positional members must come before named members EXIT CODE: 255 diff --git a/executable_semantics/testdata/fun_recur.carbon b/executable_semantics/testdata/fun_recur.carbon index 13a3924a631b..2f515e065b60 100644 --- a/executable_semantics/testdata/fun_recur.carbon +++ b/executable_semantics/testdata/fun_recur.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn f(x: i32) -> i32 { if (x == 0) { return x; diff --git a/executable_semantics/testdata/funptr1.carbon b/executable_semantics/testdata/funptr1.carbon index 8d7815a8c2e0..b1f4b423aaa0 100644 --- a/executable_semantics/testdata/funptr1.carbon +++ b/executable_semantics/testdata/funptr1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn add1(x: i32) -> i32 { return x + 1; } diff --git a/executable_semantics/testdata/generic_function1.carbon b/executable_semantics/testdata/generic_function1.carbon index c49619d30fe7..a0fbd8b5107c 100644 --- a/executable_semantics/testdata/generic_function1.carbon +++ b/executable_semantics/testdata/generic_function1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn id[T:! Type](x: T) -> T { return x; } diff --git a/executable_semantics/testdata/generic_function2.carbon b/executable_semantics/testdata/generic_function2.carbon index 556b8ebd1517..4c4678079ece 100644 --- a/executable_semantics/testdata/generic_function2.carbon +++ b/executable_semantics/testdata/generic_function2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn fst[T:! Type](x: T, y: T) -> T { return x; } diff --git a/executable_semantics/testdata/generic_function3.carbon b/executable_semantics/testdata/generic_function3.carbon index d73579902de1..b33c02f0f734 100644 --- a/executable_semantics/testdata/generic_function3.carbon +++ b/executable_semantics/testdata/generic_function3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn snd[T:! Type](x: i32, y: T) -> T { return y; } diff --git a/executable_semantics/testdata/generic_function_apply.carbon b/executable_semantics/testdata/generic_function_apply.carbon index ad69b7012f8c..b36f8614ca8a 100644 --- a/executable_semantics/testdata/generic_function_apply.carbon +++ b/executable_semantics/testdata/generic_function_apply.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn apply[T:! Type, U:! Type](f: fnty (T) -> U, x: T) -> U { return f(x); } diff --git a/executable_semantics/testdata/generic_function_fail1.carbon b/executable_semantics/testdata/generic_function_fail1.carbon index 0c3a19f67d57..e7f48cd91078 100644 --- a/executable_semantics/testdata/generic_function_fail1.carbon +++ b/executable_semantics/testdata/generic_function_fail1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn fst[T:! Type](x: T, y: T) -> T { return x; } diff --git a/executable_semantics/testdata/generic_function_fail1.golden b/executable_semantics/testdata/generic_function_fail1.golden index 01745cfd1b18..949f89c36e98 100644 --- a/executable_semantics/testdata/generic_function_fail1.golden +++ b/executable_semantics/testdata/generic_function_fail1.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/generic_function_fail1.carbon:10: type error in argument deduction +COMPILATION ERROR: executable_semantics/testdata/generic_function_fail1.carbon:12: type error in argument deduction expected: i32 actual: Bool EXIT CODE: 255 diff --git a/executable_semantics/testdata/generic_function_fail2.carbon b/executable_semantics/testdata/generic_function_fail2.carbon index 416ac52ae7df..e82b36942148 100644 --- a/executable_semantics/testdata/generic_function_fail2.carbon +++ b/executable_semantics/testdata/generic_function_fail2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn id[T:! Type](x: i32) -> i32 { return x; } diff --git a/executable_semantics/testdata/generic_function_fail2.golden b/executable_semantics/testdata/generic_function_fail2.golden index 42d085b1b195..aa238bc0f950 100644 --- a/executable_semantics/testdata/generic_function_fail2.golden +++ b/executable_semantics/testdata/generic_function_fail2.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/generic_function_fail2.carbon:10: could not deduce type argument for type parameter T +COMPILATION ERROR: executable_semantics/testdata/generic_function_fail2.carbon:12: could not deduce type argument for type parameter T EXIT CODE: 255 diff --git a/executable_semantics/testdata/generic_function_fail3.carbon b/executable_semantics/testdata/generic_function_fail3.carbon index 3b4ec683a592..352f48610b19 100644 --- a/executable_semantics/testdata/generic_function_fail3.carbon +++ b/executable_semantics/testdata/generic_function_fail3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn id[T:! Type](x: T) -> T { return x + 0; } diff --git a/executable_semantics/testdata/generic_function_fail3.golden b/executable_semantics/testdata/generic_function_fail3.golden index 58eac0b6c775..ec4fa10be89c 100644 --- a/executable_semantics/testdata/generic_function_fail3.golden +++ b/executable_semantics/testdata/generic_function_fail3.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/generic_function_fail3.carbon:6: type error in addition(1) +COMPILATION ERROR: executable_semantics/testdata/generic_function_fail3.carbon:8: type error in addition(1) expected: i32 actual: T EXIT CODE: 255 diff --git a/executable_semantics/testdata/generic_function_swap.carbon b/executable_semantics/testdata/generic_function_swap.carbon index 4a7bc419fb33..10ef63101ffd 100644 --- a/executable_semantics/testdata/generic_function_swap.carbon +++ b/executable_semantics/testdata/generic_function_swap.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn swap[T:! Type, U:! Type](tuple: (T, U)) -> (U, T) { return (tuple[1], tuple[0]); } diff --git a/executable_semantics/testdata/generic_function_tuple_map.carbon b/executable_semantics/testdata/generic_function_tuple_map.carbon index e73084e2ca37..6fb929ea1b28 100644 --- a/executable_semantics/testdata/generic_function_tuple_map.carbon +++ b/executable_semantics/testdata/generic_function_tuple_map.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn map[T:! Type](f: fnty (T) -> T, tuple: (T, T)) -> (T, T) { return (f(tuple[0]), f(tuple[1])); } diff --git a/executable_semantics/testdata/global_variable1.carbon b/executable_semantics/testdata/global_variable1.carbon index 59c9863880af..c00ec72ae422 100644 --- a/executable_semantics/testdata/global_variable1.carbon +++ b/executable_semantics/testdata/global_variable1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test global variable initialization and read. var zero: i32 = 0; diff --git a/executable_semantics/testdata/global_variable2.carbon b/executable_semantics/testdata/global_variable2.carbon index 43d62dfa21af..61ed5ad9db0f 100644 --- a/executable_semantics/testdata/global_variable2.carbon +++ b/executable_semantics/testdata/global_variable2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test that mutations to a global variable in one function is visible // in another function. diff --git a/executable_semantics/testdata/global_variable3.carbon b/executable_semantics/testdata/global_variable3.carbon index 3fd83e2c3b8d..1caf0e0db79c 100644 --- a/executable_semantics/testdata/global_variable3.carbon +++ b/executable_semantics/testdata/global_variable3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test type checking of global variable. Error expected. var flag: i32 = true; diff --git a/executable_semantics/testdata/global_variable3.golden b/executable_semantics/testdata/global_variable3.golden index 4d773e7732ce..1bcf3a8b007d 100644 --- a/executable_semantics/testdata/global_variable3.golden +++ b/executable_semantics/testdata/global_variable3.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/global_variable3.carbon:7: type error in initializer of variable +COMPILATION ERROR: executable_semantics/testdata/global_variable3.carbon:9: type error in initializer of variable expected: i32 actual: Bool EXIT CODE: 255 diff --git a/executable_semantics/testdata/global_variable4.carbon b/executable_semantics/testdata/global_variable4.carbon index 28c5b13c8b8b..85547c23d1cf 100644 --- a/executable_semantics/testdata/global_variable4.carbon +++ b/executable_semantics/testdata/global_variable4.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test mutation of a global variable. var zero: i32 = 1; diff --git a/executable_semantics/testdata/global_variable5.carbon b/executable_semantics/testdata/global_variable5.carbon index a528f6e93d17..cdfa9bbb78d1 100644 --- a/executable_semantics/testdata/global_variable5.carbon +++ b/executable_semantics/testdata/global_variable5.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test overshadowing of global variable. var x: i32 = 1; diff --git a/executable_semantics/testdata/global_variable5.golden b/executable_semantics/testdata/global_variable5.golden index 46bbc5460136..d120bd52d2a4 100644 --- a/executable_semantics/testdata/global_variable5.golden +++ b/executable_semantics/testdata/global_variable5.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/global_variable5.carbon:10: type error in return +COMPILATION ERROR: executable_semantics/testdata/global_variable5.carbon:12: type error in return expected: () actual: i32 EXIT CODE: 255 diff --git a/executable_semantics/testdata/global_variable6.carbon b/executable_semantics/testdata/global_variable6.carbon index b21506d09b3e..893140a76c08 100644 --- a/executable_semantics/testdata/global_variable6.carbon +++ b/executable_semantics/testdata/global_variable6.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test a global variable depending on another global. var x: i32 = 0; diff --git a/executable_semantics/testdata/global_variable7.carbon b/executable_semantics/testdata/global_variable7.carbon index fbdc37ae3e28..5e1dd2843f34 100644 --- a/executable_semantics/testdata/global_variable7.carbon +++ b/executable_semantics/testdata/global_variable7.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test a global variable depending on a function. fn f() -> i32 { diff --git a/executable_semantics/testdata/global_variable8.carbon b/executable_semantics/testdata/global_variable8.carbon index 7b5379ce4355..84bb66471679 100644 --- a/executable_semantics/testdata/global_variable8.carbon +++ b/executable_semantics/testdata/global_variable8.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test that a global variable may not depend on a later global. // Error expected. diff --git a/executable_semantics/testdata/global_variable8.golden b/executable_semantics/testdata/global_variable8.golden index 6ea3a1dba1cc..e73ffd2d7204 100644 --- a/executable_semantics/testdata/global_variable8.golden +++ b/executable_semantics/testdata/global_variable8.golden @@ -1,2 +1,2 @@ -RUNTIME ERROR: executable_semantics/testdata/global_variable8.carbon:8: could not find `y` +RUNTIME ERROR: executable_semantics/testdata/global_variable8.carbon:10: could not find `y` EXIT CODE: 255 diff --git a/executable_semantics/testdata/if_else.carbon b/executable_semantics/testdata/if_else.carbon index 8b0402c005a0..d28979f7d947 100644 --- a/executable_semantics/testdata/if_else.carbon +++ b/executable_semantics/testdata/if_else.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (0 == 1) { return 1; diff --git a/executable_semantics/testdata/if_else_if.carbon b/executable_semantics/testdata/if_else_if.carbon index e6d65b491a5e..37b2a25600f4 100644 --- a/executable_semantics/testdata/if_else_if.carbon +++ b/executable_semantics/testdata/if_else_if.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (0 == 1) { return 1; diff --git a/executable_semantics/testdata/if_else_if_else.carbon b/executable_semantics/testdata/if_else_if_else.carbon index 63d61ca03ae8..1b549aeda330 100644 --- a/executable_semantics/testdata/if_else_if_else.carbon +++ b/executable_semantics/testdata/if_else_if_else.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (0 == 1) { return 1; diff --git a/executable_semantics/testdata/if_false.carbon b/executable_semantics/testdata/if_false.carbon index a457ef53a5d0..822f11279d24 100644 --- a/executable_semantics/testdata/if_false.carbon +++ b/executable_semantics/testdata/if_false.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (0 == 1) { return 1; diff --git a/executable_semantics/testdata/if_nesting.carbon b/executable_semantics/testdata/if_nesting.carbon index e20a13292e92..42c064209b78 100644 --- a/executable_semantics/testdata/if_nesting.carbon +++ b/executable_semantics/testdata/if_nesting.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (0 == 0) { if (0 == 1) { diff --git a/executable_semantics/testdata/if_true.carbon b/executable_semantics/testdata/if_true.carbon index eb068817b145..44ebdf4247f7 100644 --- a/executable_semantics/testdata/if_true.carbon +++ b/executable_semantics/testdata/if_true.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { if (1 == 1) { return 0; diff --git a/executable_semantics/testdata/ignored_parameter.carbon b/executable_semantics/testdata/ignored_parameter.carbon index 0c145b98ed02..a0b371add49a 100644 --- a/executable_semantics/testdata/ignored_parameter.carbon +++ b/executable_semantics/testdata/ignored_parameter.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn ReturnSecond(_: i32, x: i32) -> i32 { return x; } diff --git a/executable_semantics/testdata/import_late.carbon b/executable_semantics/testdata/import_late.carbon new file mode 100644 index 000000000000..09d20e885c4c --- /dev/null +++ b/executable_semantics/testdata/import_late.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 + +package ExecutableSemanticsTest api; + +fn main() -> i32 { + return 0; +} + +import ExecutableSemanticsTest library "Nonexistent"; diff --git a/executable_semantics/testdata/import_late.golden b/executable_semantics/testdata/import_late.golden new file mode 100644 index 000000000000..a91a205e1caa --- /dev/null +++ b/executable_semantics/testdata/import_late.golden @@ -0,0 +1,2 @@ +COMPILATION ERROR: executable_semantics/testdata/import_late.carbon:11: syntax error, unexpected IMPORT, expecting END_OF_FILE +EXIT CODE: 255 diff --git a/executable_semantics/testdata/import_nonexistent_library.carbon b/executable_semantics/testdata/import_nonexistent_library.carbon new file mode 100644 index 000000000000..787c0b15b929 --- /dev/null +++ b/executable_semantics/testdata/import_nonexistent_library.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 + +package ExecutableSemanticsTest api; + +import Nonexistent; + +fn main() -> i32 { + return 0; +} diff --git a/executable_semantics/testdata/import_nonexistent_library.golden b/executable_semantics/testdata/import_nonexistent_library.golden new file mode 100644 index 000000000000..2db2755da426 --- /dev/null +++ b/executable_semantics/testdata/import_nonexistent_library.golden @@ -0,0 +1 @@ +result: 0 diff --git a/executable_semantics/testdata/import_nonexistent_package.carbon b/executable_semantics/testdata/import_nonexistent_package.carbon new file mode 100644 index 000000000000..ebdad887f62b --- /dev/null +++ b/executable_semantics/testdata/import_nonexistent_package.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 + +package ExecutableSemanticsTest api; + +import ExecutableSemanticsTest library "Nonexistent"; + +fn main() -> i32 { + return 0; +} diff --git a/executable_semantics/testdata/import_nonexistent_package.golden b/executable_semantics/testdata/import_nonexistent_package.golden new file mode 100644 index 000000000000..2db2755da426 --- /dev/null +++ b/executable_semantics/testdata/import_nonexistent_package.golden @@ -0,0 +1 @@ +result: 0 diff --git a/executable_semantics/testdata/match_any_int.carbon b/executable_semantics/testdata/match_any_int.carbon index 8f7393d70cc4..00dd65e3a35e 100644 --- a/executable_semantics/testdata/match_any_int.carbon +++ b/executable_semantics/testdata/match_any_int.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = 5; match (t) { diff --git a/executable_semantics/testdata/match_int.carbon b/executable_semantics/testdata/match_int.carbon index f4f43cd9fb55..f31e4e275fa6 100644 --- a/executable_semantics/testdata/match_int.carbon +++ b/executable_semantics/testdata/match_int.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = 5; match (t) { diff --git a/executable_semantics/testdata/match_int_default.carbon b/executable_semantics/testdata/match_int_default.carbon index 41a7b7708929..274d6ee1fc45 100644 --- a/executable_semantics/testdata/match_int_default.carbon +++ b/executable_semantics/testdata/match_int_default.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = 5; match (t) { diff --git a/executable_semantics/testdata/match_placeholder.carbon b/executable_semantics/testdata/match_placeholder.carbon index c0d3fc787779..e86732e12269 100644 --- a/executable_semantics/testdata/match_placeholder.carbon +++ b/executable_semantics/testdata/match_placeholder.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = (1, 2, 3, 4); match (t) { diff --git a/executable_semantics/testdata/next.carbon b/executable_semantics/testdata/next.carbon index c64099d30d4b..cb2452b85162 100644 --- a/executable_semantics/testdata/next.carbon +++ b/executable_semantics/testdata/next.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main () -> i32 { var x: i32 = 0; diff --git a/executable_semantics/testdata/no_match.carbon b/executable_semantics/testdata/no_match.carbon index 9bb13a72650e..f05a6e8f2f5d 100644 --- a/executable_semantics/testdata/no_match.carbon +++ b/executable_semantics/testdata/no_match.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: i32 = 0; match (x) { diff --git a/executable_semantics/testdata/package_library.carbon b/executable_semantics/testdata/package_library.carbon new file mode 100644 index 000000000000..9572e7fc52d6 --- /dev/null +++ b/executable_semantics/testdata/package_library.carbon @@ -0,0 +1,9 @@ +// 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 + +package ExecutableSemanticsTest library "Foo" api; + +fn main() -> i32 { + return 0; +} diff --git a/executable_semantics/testdata/package_library.golden b/executable_semantics/testdata/package_library.golden new file mode 100644 index 000000000000..2db2755da426 --- /dev/null +++ b/executable_semantics/testdata/package_library.golden @@ -0,0 +1 @@ +result: 0 diff --git a/executable_semantics/testdata/package_missing.carbon b/executable_semantics/testdata/package_missing.carbon new file mode 100644 index 000000000000..7a87538724c8 --- /dev/null +++ b/executable_semantics/testdata/package_missing.carbon @@ -0,0 +1,7 @@ +// 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 main() -> i32 { + return 0; +} diff --git a/executable_semantics/testdata/package_missing.golden b/executable_semantics/testdata/package_missing.golden new file mode 100644 index 000000000000..e3f0427ec0c9 --- /dev/null +++ b/executable_semantics/testdata/package_missing.golden @@ -0,0 +1,2 @@ +COMPILATION ERROR: executable_semantics/testdata/package_missing.carbon:5: syntax error, unexpected FN, expecting PACKAGE +EXIT CODE: 255 diff --git a/executable_semantics/testdata/pattern_init.carbon b/executable_semantics/testdata/pattern_init.carbon index 0edfae10e329..d563802a303c 100644 --- a/executable_semantics/testdata/pattern_init.carbon +++ b/executable_semantics/testdata/pattern_init.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var (x: auto, y: auto) = (2, 3); return y - x - 1; diff --git a/executable_semantics/testdata/pattern_variable_fail.carbon b/executable_semantics/testdata/pattern_variable_fail.carbon index d4fe677c7631..ef7d063cb93c 100644 --- a/executable_semantics/testdata/pattern_variable_fail.carbon +++ b/executable_semantics/testdata/pattern_variable_fail.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { // error x : i32; diff --git a/executable_semantics/testdata/pattern_variable_fail.golden b/executable_semantics/testdata/pattern_variable_fail.golden index f4fa2b5fb27d..da738c81abb5 100644 --- a/executable_semantics/testdata/pattern_variable_fail.golden +++ b/executable_semantics/testdata/pattern_variable_fail.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/pattern_variable_fail.carbon:7: syntax error, unexpected COLON +COMPILATION ERROR: executable_semantics/testdata/pattern_variable_fail.carbon:9: syntax error, unexpected COLON EXIT CODE: 255 diff --git a/executable_semantics/testdata/placeholder_variable.carbon b/executable_semantics/testdata/placeholder_variable.carbon index 0d774ed46f38..3f3afbc442b0 100644 --- a/executable_semantics/testdata/placeholder_variable.carbon +++ b/executable_semantics/testdata/placeholder_variable.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var _: auto = 1; return 0; diff --git a/executable_semantics/testdata/print1.carbon b/executable_semantics/testdata/print1.carbon index 36a518fb10a0..2ef1d7e53ba1 100644 --- a/executable_semantics/testdata/print1.carbon +++ b/executable_semantics/testdata/print1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var s: auto = "Hello world!\n"; Print(s); diff --git a/executable_semantics/testdata/record1.carbon b/executable_semantics/testdata/record1.carbon index 88acdcccdf15..827d555f6b77 100644 --- a/executable_semantics/testdata/record1.carbon +++ b/executable_semantics/testdata/record1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t2: (.x = i32, .y = i32) = (.x = 2, .y = 5); t2.y = 3; diff --git a/executable_semantics/testdata/return_auto.carbon b/executable_semantics/testdata/return_auto.carbon index 9a603ad2e9ba..7da2486a862e 100644 --- a/executable_semantics/testdata/return_auto.carbon +++ b/executable_semantics/testdata/return_auto.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() -> auto { return 0; } diff --git a/executable_semantics/testdata/return_auto.golden b/executable_semantics/testdata/return_auto.golden index af691c27f45a..535e5ceca5a3 100644 --- a/executable_semantics/testdata/return_auto.golden +++ b/executable_semantics/testdata/return_auto.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/return_auto.carbon:5: syntax error, unexpected AUTO +COMPILATION ERROR: executable_semantics/testdata/return_auto.carbon:7: syntax error, unexpected AUTO EXIT CODE: 255 diff --git a/executable_semantics/testdata/return_empty_explicit.carbon b/executable_semantics/testdata/return_empty_explicit.carbon index 5bb3bc0e3787..d2ef7ef3c791 100644 --- a/executable_semantics/testdata/return_empty_explicit.carbon +++ b/executable_semantics/testdata/return_empty_explicit.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() -> () { return (); } diff --git a/executable_semantics/testdata/return_empty_explicit_fail.carbon b/executable_semantics/testdata/return_empty_explicit_fail.carbon index f4b8d8dfb18c..9132bdd44be2 100644 --- a/executable_semantics/testdata/return_empty_explicit_fail.carbon +++ b/executable_semantics/testdata/return_empty_explicit_fail.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() { return (); } diff --git a/executable_semantics/testdata/return_empty_explicit_fail.golden b/executable_semantics/testdata/return_empty_explicit_fail.golden index ffb01fe18414..c06187d107f6 100644 --- a/executable_semantics/testdata/return_empty_explicit_fail.golden +++ b/executable_semantics/testdata/return_empty_explicit_fail.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/return_empty_explicit_fail.carbon:6: return (); should not provide a return value, to match the function's signature. +COMPILATION ERROR: executable_semantics/testdata/return_empty_explicit_fail.carbon:8: return (); should not provide a return value, to match the function's signature. EXIT CODE: 255 diff --git a/executable_semantics/testdata/return_empty_implicit1.carbon b/executable_semantics/testdata/return_empty_implicit1.carbon index 1a58d4649cb1..33d120730f00 100644 --- a/executable_semantics/testdata/return_empty_implicit1.carbon +++ b/executable_semantics/testdata/return_empty_implicit1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() { } diff --git a/executable_semantics/testdata/return_empty_implicit2.carbon b/executable_semantics/testdata/return_empty_implicit2.carbon index 9d83194a62f3..5bb27d7df2ab 100644 --- a/executable_semantics/testdata/return_empty_implicit2.carbon +++ b/executable_semantics/testdata/return_empty_implicit2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() { return; } diff --git a/executable_semantics/testdata/return_empty_implicit_fail1.carbon b/executable_semantics/testdata/return_empty_implicit_fail1.carbon index 8dfd995786bc..613543fe756b 100644 --- a/executable_semantics/testdata/return_empty_implicit_fail1.carbon +++ b/executable_semantics/testdata/return_empty_implicit_fail1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() -> () { } diff --git a/executable_semantics/testdata/return_empty_implicit_fail1.golden b/executable_semantics/testdata/return_empty_implicit_fail1.golden index 70cc48626543..1b758dc4c992 100644 --- a/executable_semantics/testdata/return_empty_implicit_fail1.golden +++ b/executable_semantics/testdata/return_empty_implicit_fail1.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail1.carbon:6: control-flow reaches end of function that provides a `->` return type without reaching a return statement +COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail1.carbon:8: control-flow reaches end of function that provides a `->` return type without reaching a return statement EXIT CODE: 255 diff --git a/executable_semantics/testdata/return_empty_implicit_fail2.carbon b/executable_semantics/testdata/return_empty_implicit_fail2.carbon index 14c0bdc0d9bf..f9971ef96d76 100644 --- a/executable_semantics/testdata/return_empty_implicit_fail2.carbon +++ b/executable_semantics/testdata/return_empty_implicit_fail2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn F() -> () { return; } diff --git a/executable_semantics/testdata/return_empty_implicit_fail2.golden b/executable_semantics/testdata/return_empty_implicit_fail2.golden index d0e0e17d94a9..ffddb39c077e 100644 --- a/executable_semantics/testdata/return_empty_implicit_fail2.golden +++ b/executable_semantics/testdata/return_empty_implicit_fail2.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail2.carbon:6: return; should provide a return value, to match the function's signature. +COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail2.carbon:8: return; should provide a return value, to match the function's signature. EXIT CODE: 255 diff --git a/executable_semantics/testdata/star.carbon b/executable_semantics/testdata/star.carbon index 58bbb3e34c51..c1bdd09d3ac3 100644 --- a/executable_semantics/testdata/star.carbon +++ b/executable_semantics/testdata/star.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Never actually called, so this only tests typechecking and semantic analysis. fn F(n: i32, p: i32*, q: i32***) -> i32* { var a: i32 = n * *p; diff --git a/executable_semantics/testdata/string1.carbon b/executable_semantics/testdata/string1.carbon index 6a37547e96d0..4405fe85fae8 100644 --- a/executable_semantics/testdata/string1.carbon +++ b/executable_semantics/testdata/string1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn CompareStr(s: String) -> i32 { if (s == "str") { return 0; diff --git a/executable_semantics/testdata/string2.carbon b/executable_semantics/testdata/string2.carbon index 9741a975a71d..449c7aa2b903 100644 --- a/executable_semantics/testdata/string2.carbon +++ b/executable_semantics/testdata/string2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn CompareStr(s: String) -> i32 { if (s == "str\n") { return 0; diff --git a/executable_semantics/testdata/string3.carbon b/executable_semantics/testdata/string3.carbon index e2642919ab46..36b91c496592 100644 --- a/executable_semantics/testdata/string3.carbon +++ b/executable_semantics/testdata/string3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn CompareStr(s: String) -> i32 { if (s == "str;") { return 0; diff --git a/executable_semantics/testdata/string_fail1.carbon b/executable_semantics/testdata/string_fail1.carbon index 6a9e4f3b8918..67eed54704d9 100644 --- a/executable_semantics/testdata/string_fail1.carbon +++ b/executable_semantics/testdata/string_fail1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("str\e"); return 0; diff --git a/executable_semantics/testdata/string_fail1.golden b/executable_semantics/testdata/string_fail1.golden index 1f6df390396b..80e4740bbc87 100644 --- a/executable_semantics/testdata/string_fail1.golden +++ b/executable_semantics/testdata/string_fail1.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail1.carbon:6: Invalid escaping in string: "str\e" +COMPILATION ERROR: executable_semantics/testdata/string_fail1.carbon:8: Invalid escaping in string: "str\e" EXIT CODE: 255 diff --git a/executable_semantics/testdata/string_fail2.carbon b/executable_semantics/testdata/string_fail2.carbon index 6da2b1e03c42..ee59b401aab0 100644 --- a/executable_semantics/testdata/string_fail2.carbon +++ b/executable_semantics/testdata/string_fail2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("str\x"); return 0; diff --git a/executable_semantics/testdata/string_fail2.golden b/executable_semantics/testdata/string_fail2.golden index 2b97b5f0cfc6..082579f4e8f9 100644 --- a/executable_semantics/testdata/string_fail2.golden +++ b/executable_semantics/testdata/string_fail2.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail2.carbon:6: Invalid escaping in string: "str\x" +COMPILATION ERROR: executable_semantics/testdata/string_fail2.carbon:8: Invalid escaping in string: "str\x" EXIT CODE: 255 diff --git a/executable_semantics/testdata/string_fail3.carbon b/executable_semantics/testdata/string_fail3.carbon index f73b94ac07a7..1d29b32ef7a2 100644 --- a/executable_semantics/testdata/string_fail3.carbon +++ b/executable_semantics/testdata/string_fail3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("str\xaa"); return 0; diff --git a/executable_semantics/testdata/string_fail3.golden b/executable_semantics/testdata/string_fail3.golden index 9b594ffd8f79..ab8183d12496 100644 --- a/executable_semantics/testdata/string_fail3.golden +++ b/executable_semantics/testdata/string_fail3.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail3.carbon:6: Invalid escaping in string: "str\xaa" +COMPILATION ERROR: executable_semantics/testdata/string_fail3.carbon:8: Invalid escaping in string: "str\xaa" EXIT CODE: 255 diff --git a/executable_semantics/testdata/string_fail4.carbon b/executable_semantics/testdata/string_fail4.carbon index 438ac819f031..db1679afe72e 100644 --- a/executable_semantics/testdata/string_fail4.carbon +++ b/executable_semantics/testdata/string_fail4.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("str\01"); return 0; diff --git a/executable_semantics/testdata/string_fail4.golden b/executable_semantics/testdata/string_fail4.golden index 8d1f9466af7f..e6a4890ca300 100644 --- a/executable_semantics/testdata/string_fail4.golden +++ b/executable_semantics/testdata/string_fail4.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail4.carbon:6: Invalid escaping in string: "str\01" +COMPILATION ERROR: executable_semantics/testdata/string_fail4.carbon:8: Invalid escaping in string: "str\01" EXIT CODE: 255 diff --git a/executable_semantics/testdata/string_fail5.carbon b/executable_semantics/testdata/string_fail5.carbon index 0d4ef060cf6a..7d22e729deae 100644 --- a/executable_semantics/testdata/string_fail5.carbon +++ b/executable_semantics/testdata/string_fail5.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("new line"); diff --git a/executable_semantics/testdata/string_fail5.golden b/executable_semantics/testdata/string_fail5.golden index cb2e7da40069..2fb63e7df106 100644 --- a/executable_semantics/testdata/string_fail5.golden +++ b/executable_semantics/testdata/string_fail5.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail5.carbon:6: invalid character '\x22' in source file. +COMPILATION ERROR: executable_semantics/testdata/string_fail5.carbon:8: invalid character '\x22' in source file. EXIT CODE: 255 diff --git a/executable_semantics/testdata/string_fail6.carbon b/executable_semantics/testdata/string_fail6.carbon index 6e37042affa0..b418a5c6c6dd 100644 --- a/executable_semantics/testdata/string_fail6.carbon +++ b/executable_semantics/testdata/string_fail6.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { Print("new line"); return 0; diff --git a/executable_semantics/testdata/string_fail6.golden b/executable_semantics/testdata/string_fail6.golden index 16d7b0d9a7ac..25467b3a874a 100644 --- a/executable_semantics/testdata/string_fail6.golden +++ b/executable_semantics/testdata/string_fail6.golden @@ -1,2 +1,2 @@ -COMPILATION ERROR: executable_semantics/testdata/string_fail6.carbon:6: Invalid escaping in string: "new line" +COMPILATION ERROR: executable_semantics/testdata/string_fail6.carbon:8: Invalid escaping in string: "new line" EXIT CODE: 255 diff --git a/executable_semantics/testdata/tuple1.carbon b/executable_semantics/testdata/tuple1.carbon index 455ee40864a4..1cf887a99e9b 100644 --- a/executable_semantics/testdata/tuple1.carbon +++ b/executable_semantics/testdata/tuple1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: i32 = (1); var t2: (i32,i32) = (5, 2); diff --git a/executable_semantics/testdata/tuple2.carbon b/executable_semantics/testdata/tuple2.carbon index ebaaffd8e00c..d306a662a69f 100644 --- a/executable_semantics/testdata/tuple2.carbon +++ b/executable_semantics/testdata/tuple2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t1: (i32,) = (5,); var t2: (i32, i32) = (2, 3,); diff --git a/executable_semantics/testdata/tuple3.carbon b/executable_semantics/testdata/tuple3.carbon index 9fb60c2b47eb..92e2f79942cc 100644 --- a/executable_semantics/testdata/tuple3.carbon +++ b/executable_semantics/testdata/tuple3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: (i32, .x = i32) = (3, .x = 2); return t.x + 1 - t[0]; diff --git a/executable_semantics/testdata/tuple4.carbon b/executable_semantics/testdata/tuple4.carbon index 956483aacb37..81e357402677 100644 --- a/executable_semantics/testdata/tuple4.carbon +++ b/executable_semantics/testdata/tuple4.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = (.x = 2, 3); return 0; diff --git a/executable_semantics/testdata/tuple4.golden b/executable_semantics/testdata/tuple4.golden index 6d03bdae31f7..f65afac4c2ea 100644 --- a/executable_semantics/testdata/tuple4.golden +++ b/executable_semantics/testdata/tuple4.golden @@ -1,2 +1,2 @@ -PROGRAM ERROR: executable_semantics/testdata/tuple4.carbon:6: positional members must come before named members +PROGRAM ERROR: executable_semantics/testdata/tuple4.carbon:8: positional members must come before named members EXIT CODE: 255 diff --git a/executable_semantics/testdata/tuple5.carbon b/executable_semantics/testdata/tuple5.carbon index d40779c29f90..e9b5ee2d9fdd 100644 --- a/executable_semantics/testdata/tuple5.carbon +++ b/executable_semantics/testdata/tuple5.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test the that field order matters for tuples. fn main() -> i32 { diff --git a/executable_semantics/testdata/tuple5.golden b/executable_semantics/testdata/tuple5.golden index 4860ba283c5d..fcb8cdbc1969 100644 --- a/executable_semantics/testdata/tuple5.golden +++ b/executable_semantics/testdata/tuple5.golden @@ -1,2 +1,2 @@ -PROGRAM ERROR: executable_semantics/testdata/tuple5.carbon:8: Tuple field name 'y' does not match pattern field name 'x' +PROGRAM ERROR: executable_semantics/testdata/tuple5.carbon:10: Tuple field name 'y' does not match pattern field name 'x' EXIT CODE: 255 diff --git a/executable_semantics/testdata/tuple_assign.carbon b/executable_semantics/testdata/tuple_assign.carbon index f8717764c7a0..2d9af23520b0 100644 --- a/executable_semantics/testdata/tuple_assign.carbon +++ b/executable_semantics/testdata/tuple_assign.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: auto = 0; var y: auto = 1; diff --git a/executable_semantics/testdata/tuple_equality.carbon b/executable_semantics/testdata/tuple_equality.carbon index fcc1cf21f083..b77b5ac6dbce 100644 --- a/executable_semantics/testdata/tuple_equality.carbon +++ b/executable_semantics/testdata/tuple_equality.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t1: (i32,i32) = (5, 2); var t2: (i32,i32) = (5, 2); diff --git a/executable_semantics/testdata/tuple_equality2.carbon b/executable_semantics/testdata/tuple_equality2.carbon index 507ebe1a1446..be5821bef8c3 100644 --- a/executable_semantics/testdata/tuple_equality2.carbon +++ b/executable_semantics/testdata/tuple_equality2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t1: (i32,i32) = (5, 2); var t2: (i32,i32) = (5, 4); diff --git a/executable_semantics/testdata/tuple_equality3.carbon b/executable_semantics/testdata/tuple_equality3.carbon index 00a694a1c5f5..0f7b119d67f6 100644 --- a/executable_semantics/testdata/tuple_equality3.carbon +++ b/executable_semantics/testdata/tuple_equality3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t1: (i32,i32) = (5, 2); var t2: (i32,) = (5,); diff --git a/executable_semantics/testdata/tuple_equality3.golden b/executable_semantics/testdata/tuple_equality3.golden index bd6c8490f6a5..2b6f0679e047 100644 --- a/executable_semantics/testdata/tuple_equality3.golden +++ b/executable_semantics/testdata/tuple_equality3.golden @@ -1,4 +1,4 @@ -COMPILATION ERROR: executable_semantics/testdata/tuple_equality3.carbon:8: type error in == +COMPILATION ERROR: executable_semantics/testdata/tuple_equality3.carbon:10: type error in == expected: (0 = i32, 1 = i32) actual: (0 = i32) EXIT CODE: 255 diff --git a/executable_semantics/testdata/tuple_match.carbon b/executable_semantics/testdata/tuple_match.carbon index 9a54232ad7b0..c3d558b4d2c7 100644 --- a/executable_semantics/testdata/tuple_match.carbon +++ b/executable_semantics/testdata/tuple_match.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: auto = (5, 2); match (t) { diff --git a/executable_semantics/testdata/tuple_match2.carbon b/executable_semantics/testdata/tuple_match2.carbon index 2f79de431b6c..1179d06bde78 100644 --- a/executable_semantics/testdata/tuple_match2.carbon +++ b/executable_semantics/testdata/tuple_match2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test matching with a mixture of positional and named fields. fn main() -> i32 { diff --git a/executable_semantics/testdata/tuple_match3.carbon b/executable_semantics/testdata/tuple_match3.carbon index f65310fd5388..00529664b0fa 100644 --- a/executable_semantics/testdata/tuple_match3.carbon +++ b/executable_semantics/testdata/tuple_match3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + // Test matching of a tuple inside a tuple. fn main() -> i32 { diff --git a/executable_semantics/testdata/type_compute.carbon b/executable_semantics/testdata/type_compute.carbon index b7df36f7e170..7d8fe94715fc 100644 --- a/executable_semantics/testdata/type_compute.carbon +++ b/executable_semantics/testdata/type_compute.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn Id(t: Type) => t; // Test non-trivial type expression in variable declaration statement. diff --git a/executable_semantics/testdata/type_compute2.carbon b/executable_semantics/testdata/type_compute2.carbon index 7f7322b03f93..6336d982cea8 100644 --- a/executable_semantics/testdata/type_compute2.carbon +++ b/executable_semantics/testdata/type_compute2.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn Id(t: Type) => t; // Test non-trivial type expression in return type. diff --git a/executable_semantics/testdata/type_compute3.carbon b/executable_semantics/testdata/type_compute3.carbon index 424a8dd7258e..4125272eec91 100644 --- a/executable_semantics/testdata/type_compute3.carbon +++ b/executable_semantics/testdata/type_compute3.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn Id(t: Type) => t; // Test non-trivial type expression in parameter type. diff --git a/executable_semantics/testdata/type_match.carbon b/executable_semantics/testdata/type_match.carbon index 8b2cb59635bb..2b838ac1f8bd 100644 --- a/executable_semantics/testdata/type_match.carbon +++ b/executable_semantics/testdata/type_match.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var t: (auto, (i32, i32)) = ((1,2),(3,4)); return t[0][0] + t[1][1] - 5; diff --git a/executable_semantics/testdata/while1.carbon b/executable_semantics/testdata/while1.carbon index 5215e4000fa1..fd42d3aa4e2d 100644 --- a/executable_semantics/testdata/while1.carbon +++ b/executable_semantics/testdata/while1.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { var x: auto = 2; while (not (x == 0)) { diff --git a/executable_semantics/testdata/zero.carbon b/executable_semantics/testdata/zero.carbon index 7a87538724c8..2cf5bf104a42 100644 --- a/executable_semantics/testdata/zero.carbon +++ b/executable_semantics/testdata/zero.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +package ExecutableSemanticsTest api; + fn main() -> i32 { return 0; } diff --git a/executable_semantics/tests.py b/executable_semantics/tests.py index b90664f0bb5b..2406f6eb0417 100755 --- a/executable_semantics/tests.py +++ b/executable_semantics/tests.py @@ -103,10 +103,9 @@ def _update_list(use_git_state): # Garbage collect unnecessary golden files. for golden in sorted(goldens): if golden not in tests: - print( - "Removing golden '%s.golden' because it has no test." % golden - ) - os.unlink(os.path.join(_TESTDATA, golden)) + filename = "%s.golden" % golden + print("Removing golden '%s' because it has no test." % filename) + os.unlink(os.path.join(_TESTDATA, filename)) def _update_golden(test):