equality_false.carbon 812 B

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: result: 0
  9. package ExplorerTest api;
  10. // TODO: Implement this with some kind of reflection?
  11. external impl {.x: i32, .y: i32} as EqWith(Self) {
  12. fn Equal[self: Self](other: Self) -> bool {
  13. return self.x == other.x and self.y == other.y;
  14. }
  15. fn NotEqual[self: Self](other: Self) -> bool {
  16. return self.x != other.x or self.y != other.y;
  17. }
  18. }
  19. fn Main() -> i32 {
  20. var t1: {.x: i32, .y: i32} = {.x = 5, .y = 2};
  21. var t2: {.x: i32, .y: i32} = {.x = 5, .y = 4};
  22. if (t1 == t2) {
  23. return 1;
  24. } else {
  25. return 0;
  26. }
  27. }