builtin_comparsion.carbon 1.1 KB

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