sub_builtin.carbon 650 B

12345678910111213141516171819202122
  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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: Interface: 5
  9. // CHECK:STDOUT: Op: 5
  10. // CHECK:STDOUT: result: 0
  11. package ExplorerTest api;
  12. fn Main() -> i32 {
  13. var lhs: i32 = 8;
  14. var rhs: i32 = 3;
  15. // Make sure that both the interface and operator work with i32. These rely on
  16. // builtin arithmetic more directly.
  17. Print("Interface: {0}", lhs.(SubWith(i32).Op)(rhs));
  18. Print("Op: {0}", lhs - rhs);
  19. return 0;
  20. }