builtin_comparsion.carbon 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. // RUN: %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. // CHECK: strings less: 1
  11. // CHECK: ints less: 0
  12. // CHECK: strings less eq: 1
  13. // CHECK: ints less eq: 1
  14. // CHECK: strings greater: 0
  15. // CHECK: ints greater: 0
  16. // CHECK: strings greater eq: 0
  17. // CHECK: ints greater eq: 1
  18. // CHECK: result: 0
  19. package ExplorerTest api;
  20. fn Main() -> i32 {
  21. Print("strings less: {0}", if "hello" < "world" then 1 else 0);
  22. Print("ints less: {0}", if 1 < 1 then 1 else 0);
  23. Print("strings less eq: {0}", if "hello" <= "world" then 1 else 0);
  24. Print("ints less eq: {0}", if 1 <= 1 then 1 else 0);
  25. Print("strings greater: {0}", if "hello" > "world" then 1 else 0);
  26. Print("ints greater: {0}", if 1 > 1 then 1 else 0);
  27. Print("strings greater eq: {0}", if "hello" >= "world" then 1 else 0);
  28. Print("ints greater eq: {0}", if 1 >= 1 then 1 else 0);
  29. return 0;
  30. }