add_builtin.carbon 597 B

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