shift.carbon 942 B

123456789101112131415161718192021222324252627
  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: result: 0
  11. package ExplorerTest api;
  12. fn Main() -> i32 {
  13. if (not (1 << 0 == 1)) { return 1; }
  14. if (not (1 << 3 == 8)) { return 2; }
  15. if (not (0 << 3 == 0)) { return 3; }
  16. if (not (3 << 1 == 6)) { return 4; }
  17. if (not (-1 << 2 == -4)) { return 5; }
  18. if (not (1 >> 0 == 1)) { return 6; }
  19. if (not (1 >> 1 == 0)) { return 7; }
  20. if (not (3 >> 1 == 1)) { return 8; }
  21. if (not (-1 >> 1 == -1)) { return 9; }
  22. if (not (-2 >> 1 == -1)) { return 10; }
  23. return 0;
  24. }