negate_builtin.carbon 564 B

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