greater.carbon 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. // EXTRA-ARGS: --no-dump-sem-ir
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/greater.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/greater.carbon
  12. // --- int_greater.carbon
  13. fn Greater(a: i32, b: i32) -> bool = "int.greater";
  14. fn Negate(a: i32) -> i32 = "int.snegate";
  15. class True {}
  16. class False {}
  17. fn F(true_: True, false_: False) {
  18. false_ as (if Greater(1, 2) then True else False);
  19. false_ as (if Greater(1, 1) then True else False);
  20. true_ as (if Greater(1, 0) then True else False);
  21. false_ as (if Greater(Negate(1), 0) then True else False);
  22. true_ as (if Greater(0, Negate(1)) then True else False);
  23. }
  24. fn RuntimeCallIsValid(a: i32, b: i32) -> bool {
  25. return Greater(a, b);
  26. }