mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Provide local paths for file tests. (#2830)
The intent of this change is that instead of paths looking like `explorer/testdata/foo/bar.carbon` (repo-relative), they're now just `bar.carbon` (local). The consequence is that paths should be a bit more durable in various environments, and just paths should be shorter and easier to read. The explorer's prelude is an exception to this since it comes from data, rather than being the test target. Due to the change in approaches, it needs the regex again. Uses #2829
This commit is contained in:
@@ -12,7 +12,7 @@ base class C {
|
||||
class D extends C {
|
||||
abstract fn Foo[self:Self]() -> i32 {
|
||||
return 1;
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_abstract_method_not_supported.carbon:[[@LINE+1]]: Error declaring `Foo`: `abstract` methods are not yet supported.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_abstract_method_not_supported.carbon:[[@LINE+1]]: Error declaring `Foo`: `abstract` methods are not yet supported.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package ExplorerTest api;
|
||||
|
||||
class A {
|
||||
fn F[self: Self]() -> type {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_call_method_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `F` that has not been fully type-checked
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_call_method_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `F` that has not been fully type-checked
|
||||
var a: ({} as A).F() = 0;
|
||||
return i32;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ class A {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var a: A = {};
|
||||
// CHECK:STDERR: RUNTIME ERROR: explorer/testdata/class/fail_call_undefined_method.carbon:[[@LINE+1]]: attempt to call function `F` that has not been defined
|
||||
// CHECK:STDERR: RUNTIME ERROR: fail_call_undefined_method.carbon:[[@LINE+1]]: attempt to call function `F` that has not been defined
|
||||
return a.F();
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
package ExplorerTest api;
|
||||
|
||||
// Error: Can't use keyword `Self` as the name of a class.
|
||||
// CHECK:STDERR: SYNTAX ERROR: explorer/testdata/class/fail_class_named_self.carbon:[[@LINE+1]]: syntax error, unexpected SELF, expecting identifier or LEFT_PARENTHESIS
|
||||
// CHECK:STDERR: SYNTAX ERROR: fail_class_named_self.carbon:[[@LINE+1]]: syntax error, unexpected SELF, expecting identifier or LEFT_PARENTHESIS
|
||||
class Self {
|
||||
var x: i32;
|
||||
var y: i32;
|
||||
|
||||
@@ -15,7 +15,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_direct_base_class_init.carbon:[[@LINE+1]]: type error in initializer of variable: '{.a: i32, .b: i32}' is not implicitly convertible to 'class B'
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_direct_base_class_init.carbon:[[@LINE+1]]: type error in initializer of variable: '{.a: i32, .b: i32}' is not implicitly convertible to 'class B'
|
||||
var b: B = {.a=0, .b=1};
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class C {
|
||||
|
||||
class D extends C {
|
||||
fn G() {}
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_extends_final_class.carbon:[[@LINE+1]]: Base class `C` is `final` and cannot be inherited. Add the `base` or `abstract` class prefix to `C` to allow it to be inherited
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_extends_final_class.carbon:[[@LINE+1]]: Base class `C` is `final` and cannot be inherited. Add the `base` or `abstract` class prefix to `C` to allow it to be inherited
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
package ExplorerTest api;
|
||||
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_extends_non_class.carbon:[[@LINE+1]]: type error in type expression: 'i32' is not implicitly convertible to 'type'
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_extends_non_class.carbon:[[@LINE+1]]: type error in type expression: 'i32' is not implicitly convertible to 'type'
|
||||
class C extends 3 {
|
||||
var x: i32;
|
||||
var y: i32;
|
||||
|
||||
@@ -13,6 +13,6 @@ class Point {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var p: Point = {.x = 1, .y = 2};
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_field_access_mismatch.carbon:[[@LINE+1]]: class Point does not have a field named z
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_field_access_mismatch.carbon:[[@LINE+1]]: class Point does not have a field named z
|
||||
return p.z - 1;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ class Point3D extends Point {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var p: Point3D = {.base={.x = 1, .y = 2}, .z = 3};
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_field_access_mismatch_base.carbon:[[@LINE+1]]: class Point3D does not have a field named a
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_field_access_mismatch_base.carbon:[[@LINE+1]]: class Point3D does not have a field named a
|
||||
return p.a;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class Point3D extends Point {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var p: Point3D = {.base={.x = 1, .y = 2}, .z = 3};
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_field_assign_mismatch_base.carbon:[[@LINE+1]]: class Point3D does not have a field named a
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_field_assign_mismatch_base.carbon:[[@LINE+1]]: class Point3D does not have a field named a
|
||||
p.a = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class Point {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_field_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: '{.x: i32, .z: i32}' is not implicitly convertible to 'class Point'
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_field_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: '{.x: i32, .z: i32}' is not implicitly convertible to 'class Point'
|
||||
var p: Point = {.x = 1, .z = 2};
|
||||
return p.x - 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class Point {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_field_missing.carbon:[[@LINE+1]]: type error in initializer of variable: '{.x: i32}' is not implicitly convertible to 'class Point'
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_field_missing.carbon:[[@LINE+1]]: type error in initializer of variable: '{.x: i32}' is not implicitly convertible to 'class Point'
|
||||
var p: Point = {.x = 1};
|
||||
return p.x - 1;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ base class C {
|
||||
class D extends C {
|
||||
impl fn Foo[self:Self]() -> i32 {
|
||||
return 1;
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_impl_method_not_existing.carbon:[[@LINE+1]]: Error declaring `Foo`: cannot override a method that is not declared `abstract` or `virtual` in base class.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_impl_method_not_existing.carbon:[[@LINE+1]]: Error declaring `Foo`: cannot override a method that is not declared `abstract` or `virtual` in base class.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ base class C {
|
||||
class D extends C {
|
||||
impl fn Foo[self:Self]() -> i32 {
|
||||
return 1;
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_impl_method_not_virtual.carbon:[[@LINE+1]]: Error declaring `Foo`: cannot override a method that is not declared `abstract` or `virtual` in base class.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_impl_method_not_virtual.carbon:[[@LINE+1]]: Error declaring `Foo`: cannot override a method that is not declared `abstract` or `virtual` in base class.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ abstract class C {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_instantiate_abstract_class_constructor.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_instantiate_abstract_class_constructor.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
var c: C = C.Create();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ abstract class C {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_instantiate_abstract_class_empty.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_instantiate_abstract_class_empty.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
var c: C;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ abstract class C {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_instantiate_abstract_class_struct.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_instantiate_abstract_class_struct.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
|
||||
var c: C = { .a = 1 };
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class D {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var d: D = {};
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_invalid_subtyping.carbon:[[@LINE+1]]: type error in initializer of variable: 'class D*' is not implicitly convertible to 'class C*'
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_invalid_subtyping.carbon:[[@LINE+1]]: type error in initializer of variable: 'class D*' is not implicitly convertible to 'class C*'
|
||||
var c: C* = &d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class C {
|
||||
fn PickType() -> type { return i32; }
|
||||
// This is invalid even though `PickType` is defined earlier, because
|
||||
// checking of member bodies is deferred until after the class is completed.
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_member_call_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `PickType` that has not been fully type-checked
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_member_call_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `PickType` that has not been fully type-checked
|
||||
fn GetZero() -> PickType() { return 0; }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
package ExplorerTest api;
|
||||
|
||||
class C {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_member_of_self.carbon:[[@LINE+1]]: incomplete type `class C` used in type of variable
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_member_of_self.carbon:[[@LINE+1]]: incomplete type `class C` used in type of variable
|
||||
var m: Self;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ fn H[T:! type](x: T) {}
|
||||
|
||||
fn Main() -> i32 {
|
||||
H(C.F);
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_method_deduced.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_method_deduced.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
H(C.G);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,6 +20,6 @@ class Point {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_method_from_class.carbon:[[@LINE+1]]: in call `Point.GetX()`, expected callee to be a function, found `member name GetX`
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_method_from_class.carbon:[[@LINE+1]]: in call `Point.GetX()`, expected callee to be a function, found `member name GetX`
|
||||
return Point.GetX();
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ class C {
|
||||
|
||||
fn Main() -> i32 {
|
||||
var f: auto = C.F;
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_method_in_var.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_method_in_var.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
var g: auto = C.G;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -11,7 +11,7 @@ base class A {
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_override_virtual_with_non_virtual.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_override_virtual_with_non_virtual.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
|
||||
fn Foo[self: Self]() {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
package ExplorerTest api;
|
||||
|
||||
class Point {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_qualified_method.carbon:[[@LINE+1]]: qualified declaration names are not permitted in this context
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_qualified_method.carbon:[[@LINE+1]]: qualified declaration names are not permitted in this context
|
||||
fn Point.F[self: Self]() {}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ base class C {
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_redeclare_virtual_method.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_redeclare_virtual_method.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
|
||||
virtual fn Foo[self:Self]() {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class C {
|
||||
}
|
||||
|
||||
fn ReturnF() -> auto { return C.F; }
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_return_method.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_return_method.carbon:[[@LINE+1]]: member name G can only be used in a member access or alias
|
||||
fn ReturnG() -> auto { return C.G; }
|
||||
|
||||
fn Main() -> i32 {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package ExplorerTest api;
|
||||
|
||||
class C {
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_use_before_typecheck.carbon:[[@LINE+1]]: incomplete type `class C` used in member access
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_use_before_typecheck.carbon:[[@LINE+1]]: incomplete type `class C` used in member access
|
||||
var n: if not C.WrapInStruct() then i32 else {.n: i32};
|
||||
fn WrapInStruct() -> bool { return true; }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ package ExplorerTest api;
|
||||
class C {
|
||||
virtual fn Foo() -> i32 {
|
||||
return 1;
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_virtual_class_function.carbon:[[@LINE+1]]: Error declaring `Foo`: class functions cannot be virtual.
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_virtual_class_function.carbon:[[@LINE+1]]: Error declaring `Foo`: class functions cannot be virtual.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,6 @@ fn Main() -> i32 {
|
||||
var bp: B* = &b;
|
||||
var ap: A* = bp;
|
||||
// Shouldn't look into the vtable for B.
|
||||
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/fail_virtual_method_absent.carbon:[[@LINE+1]]: class A does not have a field named Foo
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_virtual_method_absent.carbon:[[@LINE+1]]: class A does not have a field named Foo
|
||||
return ap->Foo();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user