builtin_comparsion.carbon 1.0 KB

1234567891011121314151617181920212223242526272829
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. fn Main() -> i32 {
  8. Print("strings less: {0}", if "hello" < "world" then 1 else 0);
  9. Print("ints less: {0}", if 1 < 1 then 1 else 0);
  10. Print("strings less eq: {0}", if "hello" <= "world" then 1 else 0);
  11. Print("ints less eq: {0}", if 1 <= 1 then 1 else 0);
  12. Print("strings greater: {0}", if "hello" > "world" then 1 else 0);
  13. Print("ints greater: {0}", if 1 > 1 then 1 else 0);
  14. Print("strings greater eq: {0}", if "hello" >= "world" then 1 else 0);
  15. Print("ints greater eq: {0}", if 1 >= 1 then 1 else 0);
  16. return 0;
  17. }
  18. // CHECK:STDOUT: strings less: 1
  19. // CHECK:STDOUT: ints less: 0
  20. // CHECK:STDOUT: strings less eq: 1
  21. // CHECK:STDOUT: ints less eq: 1
  22. // CHECK:STDOUT: strings greater: 0
  23. // CHECK:STDOUT: ints greater: 0
  24. // CHECK:STDOUT: strings greater eq: 0
  25. // CHECK:STDOUT: ints greater eq: 1
  26. // CHECK:STDOUT: result: 0