diff --git a/explorer/testdata/operators/add_builtin.carbon b/explorer/testdata/operators/add_builtin.carbon index 7a68276a6121f..e61291de95ea3 100644 --- a/explorer/testdata/operators/add_builtin.carbon +++ b/explorer/testdata/operators/add_builtin.carbon @@ -7,13 +7,18 @@ // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \ // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s // AUTOUPDATE: %{explorer} %s -// CHECK: result: 3 +// CHECK: Interface: 5 +// CHECK: Op: 5 +// CHECK: result: 0 package ExplorerTest api; -// TODO: T:! Add -fn DoAdd[T:! AddWith(.Self) where .Result == .Self](x: T, y: T) -> T { return x + y; } - fn Main() -> i32 { - return DoAdd(1, 2); + var lhs: i32 = 3; + var rhs: i32 = 2; + // Make sure that both the interface and operator work with i32. These rely on + // builtin arithmetic more directly. + Print("Interface: {0}", lhs.(AddWith(i32).Op)(rhs)); + Print("Op: {0}", lhs + rhs); + return 0; } diff --git a/explorer/testdata/operators/mod_builtin.carbon b/explorer/testdata/operators/mod_builtin.carbon index ae04af8fda5af..cf3f2f753ed27 100644 --- a/explorer/testdata/operators/mod_builtin.carbon +++ b/explorer/testdata/operators/mod_builtin.carbon @@ -7,13 +7,18 @@ // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \ // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s // AUTOUPDATE: %{explorer} %s +// CHECK: Interface: 2 +// CHECK: Op: 2 // CHECK: result: 0 package ExplorerTest api; -// TODO: T:! Mod -fn DoMod[T:! ModWith(.Self) where .Result == .Self](x: T, y: T) -> T { return x % y; } - fn Main() -> i32 { - return DoMod(4, 2); + var lhs: i32 = 8; + var rhs: i32 = 3; + // Make sure that both the interface and operator work with i32. These rely on + // builtin arithmetic more directly. + Print("Interface: {0}", lhs.(ModWith(i32).Op)(rhs)); + Print("Op: {0}", lhs % rhs); + return 0; } diff --git a/explorer/testdata/operators/mul_builtin.carbon b/explorer/testdata/operators/mul_builtin.carbon index 2df8512560c42..563fdcc63b5b1 100644 --- a/explorer/testdata/operators/mul_builtin.carbon +++ b/explorer/testdata/operators/mul_builtin.carbon @@ -7,13 +7,18 @@ // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \ // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s // AUTOUPDATE: %{explorer} %s -// CHECK: result: 6 +// CHECK: Interface: 6 +// CHECK: Op: 6 +// CHECK: result: 0 package ExplorerTest api; -// TODO: T:! Mul -fn DoMul[T:! MulWith(.Self) where .Result == .Self](x: T, y: T) -> T { return x * y; } - fn Main() -> i32 { - return DoMul(2, 3); + var lhs: i32 = 3; + var rhs: i32 = 2; + // Make sure that both the interface and operator work with i32. These rely on + // builtin arithmetic more directly. + Print("Interface: {0}", lhs.(MulWith(i32).Op)(rhs)); + Print("Op: {0}", lhs * rhs); + return 0; } diff --git a/explorer/testdata/operators/negate_builtin.carbon b/explorer/testdata/operators/negate_builtin.carbon index bf8883e7a27f7..a9999d7171184 100644 --- a/explorer/testdata/operators/negate_builtin.carbon +++ b/explorer/testdata/operators/negate_builtin.carbon @@ -7,12 +7,17 @@ // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \ // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s // AUTOUPDATE: %{explorer} %s -// CHECK: result: -3 +// CHECK: Interface: -3 +// CHECK: Op: -3 +// CHECK: result: 0 package ExplorerTest api; -fn DoNegate[T:! Negate where .Result == .Self](x: T) -> T { return -x; } - fn Main() -> i32 { - return DoNegate(3); + var val: i32 = 3; + // Make sure that both the interface and operator work with i32. These rely on + // builtin arithmetic more directly. + Print("Interface: {0}", val.(Negate.Op)()); + Print("Op: {0}", -val); + return 0; } diff --git a/explorer/testdata/operators/sub_builtin.carbon b/explorer/testdata/operators/sub_builtin.carbon index 181102d7281fd..b328ad394cfc2 100644 --- a/explorer/testdata/operators/sub_builtin.carbon +++ b/explorer/testdata/operators/sub_builtin.carbon @@ -7,13 +7,18 @@ // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \ // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s // AUTOUPDATE: %{explorer} %s -// CHECK: result: 1 +// CHECK: Interface: 5 +// CHECK: Op: 5 +// CHECK: result: 0 package ExplorerTest api; -// TODO: T:! Sub -fn DoSub[T:! SubWith(.Self) where .Result == .Self](x: T, y: T) -> T { return x - y; } - fn Main() -> i32 { - return DoSub(3, 2); + var lhs: i32 = 8; + var rhs: i32 = 3; + // Make sure that both the interface and operator work with i32. These rely on + // builtin arithmetic more directly. + Print("Interface: {0}", lhs.(SubWith(i32).Op)(rhs)); + Print("Op: {0}", lhs - rhs); + return 0; }