equality_false.carbon 752 B

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