add_builtin.carbon 596 B

1234567891011121314151617181920
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: Interface: 5
  7. // CHECK:STDOUT: Op: 5
  8. // CHECK:STDOUT: result: 0
  9. package ExplorerTest api;
  10. fn Main() -> i32 {
  11. var lhs: i32 = 3;
  12. var rhs: i32 = 2;
  13. // Make sure that both the interface and operator work with i32. These rely on
  14. // builtin arithmetic more directly.
  15. Print("Interface: {0}", lhs.(AddWith(i32).Op)(rhs));
  16. Print("Op: {0}", lhs + rhs);
  17. return 0;
  18. }