Преглед изворни кода

Add syntax for package and library (#792)

Doesn't add much logic, only takes advantage of parser structure for the ordering enforcement.

Note import_nonexistent tests should probably fail, but writing import tests needs a chain of functionality, and I figured I'd just start adding some to validate the syntax (not adding existent imports because that'd require multi-file structure).
Jon Meow пре 4 година
родитељ
комит
a03536a196
100 измењених фајлова са 341 додато и 46 уклоњено
  1. 14 1
      executable_semantics/ast/BUILD
  2. 0 17
      executable_semantics/ast/abstract_syntax_tree.h
  3. 30 0
      executable_semantics/ast/ast.h
  4. 25 0
      executable_semantics/ast/library_name.h
  5. 1 0
      executable_semantics/interpreter/BUILD
  6. 7 7
      executable_semantics/interpreter/exec_program.cpp
  7. 2 3
      executable_semantics/interpreter/exec_program.h
  8. 1 0
      executable_semantics/syntax/BUILD
  9. 10 0
      executable_semantics/syntax/lexer.lpp
  10. 1 1
      executable_semantics/syntax/parse.h
  11. 1 1
      executable_semantics/syntax/parse_and_lex_context.h
  12. 47 3
      executable_semantics/syntax/parser.ypp
  13. 5 0
      executable_semantics/test_list.bzl
  14. 2 0
      executable_semantics/testdata/assignment_copy1.carbon
  15. 2 0
      executable_semantics/testdata/assignment_copy2.carbon
  16. 2 0
      executable_semantics/testdata/block1.carbon
  17. 2 0
      executable_semantics/testdata/block2.carbon
  18. 2 0
      executable_semantics/testdata/break1.carbon
  19. 2 0
      executable_semantics/testdata/choice1.carbon
  20. 2 0
      executable_semantics/testdata/class1.carbon
  21. 2 0
      executable_semantics/testdata/class2.carbon
  22. 2 0
      executable_semantics/testdata/class3.carbon
  23. 2 0
      executable_semantics/testdata/class_field_access_mismatch.carbon
  24. 1 1
      executable_semantics/testdata/class_field_access_mismatch.golden
  25. 2 0
      executable_semantics/testdata/class_field_mismatch.carbon
  26. 1 1
      executable_semantics/testdata/class_field_mismatch.golden
  27. 2 0
      executable_semantics/testdata/class_field_missing.carbon
  28. 1 1
      executable_semantics/testdata/class_field_missing.golden
  29. 2 0
      executable_semantics/testdata/continue1.carbon
  30. 2 0
      executable_semantics/testdata/experimental_continuation1.carbon
  31. 2 0
      executable_semantics/testdata/experimental_continuation2.carbon
  32. 2 0
      executable_semantics/testdata/experimental_continuation3.carbon
  33. 2 0
      executable_semantics/testdata/experimental_continuation4.carbon
  34. 2 0
      executable_semantics/testdata/experimental_continuation5.carbon
  35. 2 0
      executable_semantics/testdata/experimental_continuation6.carbon
  36. 2 0
      executable_semantics/testdata/experimental_continuation7.carbon
  37. 2 0
      executable_semantics/testdata/experimental_continuation8.carbon
  38. 2 0
      executable_semantics/testdata/experimental_continuation9.carbon
  39. 1 1
      executable_semantics/testdata/experimental_continuation9.golden
  40. 2 0
      executable_semantics/testdata/fun1.carbon
  41. 2 0
      executable_semantics/testdata/fun2.carbon
  42. 2 0
      executable_semantics/testdata/fun3.carbon
  43. 2 0
      executable_semantics/testdata/fun4.carbon
  44. 2 0
      executable_semantics/testdata/fun5.carbon
  45. 2 0
      executable_semantics/testdata/fun6_fail_type.carbon
  46. 1 1
      executable_semantics/testdata/fun6_fail_type.golden
  47. 2 0
      executable_semantics/testdata/fun_named_params.carbon
  48. 2 0
      executable_semantics/testdata/fun_named_params2.carbon
  49. 1 1
      executable_semantics/testdata/fun_named_params2.golden
  50. 2 0
      executable_semantics/testdata/fun_recur.carbon
  51. 2 0
      executable_semantics/testdata/funptr1.carbon
  52. 2 0
      executable_semantics/testdata/generic_function1.carbon
  53. 2 0
      executable_semantics/testdata/generic_function2.carbon
  54. 2 0
      executable_semantics/testdata/generic_function3.carbon
  55. 2 0
      executable_semantics/testdata/generic_function_apply.carbon
  56. 2 0
      executable_semantics/testdata/generic_function_fail1.carbon
  57. 1 1
      executable_semantics/testdata/generic_function_fail1.golden
  58. 2 0
      executable_semantics/testdata/generic_function_fail2.carbon
  59. 1 1
      executable_semantics/testdata/generic_function_fail2.golden
  60. 2 0
      executable_semantics/testdata/generic_function_fail3.carbon
  61. 1 1
      executable_semantics/testdata/generic_function_fail3.golden
  62. 2 0
      executable_semantics/testdata/generic_function_swap.carbon
  63. 2 0
      executable_semantics/testdata/generic_function_tuple_map.carbon
  64. 2 0
      executable_semantics/testdata/global_variable1.carbon
  65. 2 0
      executable_semantics/testdata/global_variable2.carbon
  66. 2 0
      executable_semantics/testdata/global_variable3.carbon
  67. 1 1
      executable_semantics/testdata/global_variable3.golden
  68. 2 0
      executable_semantics/testdata/global_variable4.carbon
  69. 2 0
      executable_semantics/testdata/global_variable5.carbon
  70. 1 1
      executable_semantics/testdata/global_variable5.golden
  71. 2 0
      executable_semantics/testdata/global_variable6.carbon
  72. 2 0
      executable_semantics/testdata/global_variable7.carbon
  73. 2 0
      executable_semantics/testdata/global_variable8.carbon
  74. 1 1
      executable_semantics/testdata/global_variable8.golden
  75. 2 0
      executable_semantics/testdata/if_else.carbon
  76. 2 0
      executable_semantics/testdata/if_else_if.carbon
  77. 2 0
      executable_semantics/testdata/if_else_if_else.carbon
  78. 2 0
      executable_semantics/testdata/if_false.carbon
  79. 2 0
      executable_semantics/testdata/if_nesting.carbon
  80. 2 0
      executable_semantics/testdata/if_true.carbon
  81. 2 0
      executable_semantics/testdata/ignored_parameter.carbon
  82. 11 0
      executable_semantics/testdata/import_late.carbon
  83. 2 0
      executable_semantics/testdata/import_late.golden
  84. 11 0
      executable_semantics/testdata/import_nonexistent_library.carbon
  85. 1 0
      executable_semantics/testdata/import_nonexistent_library.golden
  86. 11 0
      executable_semantics/testdata/import_nonexistent_package.carbon
  87. 1 0
      executable_semantics/testdata/import_nonexistent_package.golden
  88. 2 0
      executable_semantics/testdata/match_any_int.carbon
  89. 2 0
      executable_semantics/testdata/match_int.carbon
  90. 2 0
      executable_semantics/testdata/match_int_default.carbon
  91. 2 0
      executable_semantics/testdata/match_placeholder.carbon
  92. 2 0
      executable_semantics/testdata/next.carbon
  93. 2 0
      executable_semantics/testdata/no_match.carbon
  94. 9 0
      executable_semantics/testdata/package_library.carbon
  95. 1 0
      executable_semantics/testdata/package_library.golden
  96. 7 0
      executable_semantics/testdata/package_missing.carbon
  97. 2 0
      executable_semantics/testdata/package_missing.golden
  98. 2 0
      executable_semantics/testdata/pattern_init.carbon
  99. 2 0
      executable_semantics/testdata/pattern_variable_fail.carbon
  100. 1 1
      executable_semantics/testdata/pattern_variable_fail.golden

+ 14 - 1
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"],

+ 0 - 17
executable_semantics/ast/abstract_syntax_tree.h

@@ -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 <variant>
-
-#include "executable_semantics/ast/declaration.h"
-#include "executable_semantics/common/ptr.h"
-
-namespace Carbon {
-using AST = std::list<Ptr<const Declaration>>;
-}
-
-#endif  // EXECUTABLE_SEMANTICS_AST_ABSTRACT_SYNTAX_TREE_H_

+ 30 - 0
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 <list>
+
+#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<LibraryName> imports;
+  // The file's ordered declarations.
+  std::list<Ptr<const Declaration>> declarations;
+};
+
+}  // namespace Carbon
+
+#endif  // EXECUTABLE_SEMANTICS_AST_AST_H_

+ 25 - 0
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 <string>
+
+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_

+ 1 - 0
executable_semantics/interpreter/BUILD

@@ -43,6 +43,7 @@ cc_library(
     deps = [
         ":interpreter",
         ":type_checker",
+        "//executable_semantics/ast",
     ],
 )
 

+ 7 - 7
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<Ptr<const Declaration>>* fs) {
+static void AddIntrinsics(std::list<Ptr<const Declaration>>* declarations) {
   SourceLocation loc("<intrinsic>", 0);
   std::vector<TuplePattern::Field> print_fields = {TuplePattern::Field(
       "0", global_arena->New<BindingPattern>(
@@ -34,24 +34,24 @@ static void AddIntrinsics(std::list<Ptr<const Declaration>>* fs) {
           global_arena->New<ExpressionPattern>(
               global_arena->New<TupleLiteral>(loc)),
           /*is_omitted_return_type=*/false, print_return));
-  fs->insert(fs->begin(), print);
+  declarations->insert(declarations->begin(), print);
 }
 
-void ExecProgram(std::list<Ptr<const Declaration>> 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<Ptr<const Declaration>> 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) {

+ 2 - 3
executable_semantics/interpreter/exec_program.h

@@ -11,13 +11,12 @@
 
 #include <list>
 
-#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<Ptr<const Declaration>> fs);
+void ExecProgram(AST ast);
 
 }  // namespace Carbon
 

+ 1 - 0
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",

+ 10 - 0
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);              }

+ 1 - 1
executable_semantics/syntax/parse.h

@@ -8,7 +8,7 @@
 #include <string>
 #include <variant>
 
-#include "executable_semantics/ast/abstract_syntax_tree.h"
+#include "executable_semantics/ast/ast.h"
 
 namespace Carbon {
 

+ 1 - 1
executable_semantics/syntax/parse_and_lex_context.h

@@ -7,7 +7,7 @@
 
 #include <variant>
 
-#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 {

+ 47 - 3
executable_semantics/syntax/parser.ypp

@@ -65,7 +65,7 @@
 %code requires {
   #include <optional>
 
-  #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 <std::string> sized_type_literal
 %token <std::string> string_literal
 %type <std::string> designator
+%type <std::pair<LibraryName, bool>> package_directive
+%type <LibraryName> import_directive
+%type <std::vector<LibraryName>> import_directives
+%type <std::string> optional_library_path
+%type <bool> api_or_impl
 %type <BisonWrap<Ptr<const Declaration>>> declaration
 %type <BisonWrap<Ptr<const FunctionDefinition>>> function_declaration
 %type <BisonWrap<Ptr<const FunctionDefinition>>> 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<LibraryName>(); }
+| 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

+ 5 - 0
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",

+ 2 - 0
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 {

+ 2 - 0
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 {

+ 2 - 0
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;
   {

+ 2 - 0
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;
   {

+ 2 - 0
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) {

+ 2 - 0
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),

+ 2 - 0
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;

+ 2 - 0
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;

+ 2 - 0
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;

+ 2 - 0
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;

+ 1 - 1
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

+ 2 - 0
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;

+ 1 - 1
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

+ 2 - 0
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;

+ 1 - 1
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

+ 2 - 0
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)) {

+ 2 - 0
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 {

+ 2 - 0
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 {

+ 2 - 0
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`.
 

+ 2 - 0
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`.
 

+ 2 - 0
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 {

+ 2 - 0
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;

+ 2 - 0
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.

+ 2 - 0
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

+ 2 - 0
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.

+ 1 - 1
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

+ 2 - 0
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;
 }

+ 2 - 0
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.

+ 2 - 0
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;

+ 2 - 0
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() { }
 

+ 2 - 0
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 {

+ 2 - 0
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 {

+ 1 - 1
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

+ 2 - 0
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 {

+ 2 - 0
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 {

+ 1 - 1
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

+ 2 - 0
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;

+ 2 - 0
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;
 }

+ 2 - 0
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;
 }

+ 2 - 0
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;
 }

+ 2 - 0
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;
 }

+ 2 - 0
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);
 }

+ 2 - 0
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;
 }

+ 1 - 1
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

+ 2 - 0
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;
 }

+ 1 - 1
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

+ 2 - 0
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;
 }

+ 1 - 1
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

+ 2 - 0
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]);
 }

+ 2 - 0
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]));
 }

+ 2 - 0
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;

+ 2 - 0
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.
 

+ 2 - 0
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;

+ 1 - 1
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

+ 2 - 0
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;

+ 2 - 0
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;

+ 1 - 1
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

+ 2 - 0
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;

+ 2 - 0
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 {

+ 2 - 0
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.
 

+ 1 - 1
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

+ 2 - 0
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;

+ 2 - 0
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;

+ 2 - 0
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;

+ 2 - 0
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;

+ 2 - 0
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) {

+ 2 - 0
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;

+ 2 - 0
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;
 }

+ 11 - 0
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";

+ 2 - 0
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

+ 11 - 0
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;
+}

+ 1 - 0
executable_semantics/testdata/import_nonexistent_library.golden

@@ -0,0 +1 @@
+result: 0

+ 11 - 0
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;
+}

+ 1 - 0
executable_semantics/testdata/import_nonexistent_package.golden

@@ -0,0 +1 @@
+result: 0

+ 2 - 0
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) {

+ 2 - 0
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) {

+ 2 - 0
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) {

+ 2 - 0
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) {

+ 2 - 0
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;

+ 2 - 0
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) {

+ 9 - 0
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;
+}

+ 1 - 0
executable_semantics/testdata/package_library.golden

@@ -0,0 +1 @@
+result: 0

+ 7 - 0
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;
+}

+ 2 - 0
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

+ 2 - 0
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;

+ 2 - 0
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;

+ 1 - 1
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

Неке датотеке нису приказане због велике количине промена