bitwise.carbon 1020 B

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: result: 0
  11. package ExplorerTest api;
  12. fn Main() -> i32 {
  13. if (not (^0 == -1)) { return 11; }
  14. if (not (^1 == -2)) { return 12; }
  15. if (not (^(-3) == 2)) { return 13; }
  16. if (not (3 & 6 == 2)) { return 21; }
  17. if (not (-1 & 4 == 4)) { return 22; }
  18. if (not (-1 & -2 == -2)) { return 23; }
  19. if (not (1 | 4 == 5)) { return 31; }
  20. if (not (5 | 3 == 7)) { return 32; }
  21. if (not (-2 | 1 == -1)) { return 33; }
  22. if (not (1 ^ 4 == 5)) { return 41; }
  23. if (not (5 ^ 3 == 6)) { return 42; }
  24. if (not (-2 ^ -3 == 3)) { return 43; }
  25. return 0;
  26. }