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