Skip to content

Commit 4e32716

Browse files
committed
fix: migrate hylolib tests to have infix
1 parent afd323d commit 4e32716

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

tests/pos/hylolib/AnyValue.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class AnyValue private (
2424
_copy(this.wrapped)
2525

2626
/** Returns `true` iff `this` and `other` have an equivalent value. */
27-
def eq(other: AnyValue): Boolean =
27+
infix def eq(other: AnyValue): Boolean =
2828
_eq(this.wrapped, other.wrapped)
2929

3030
/** Hashes the salient parts of `this` into `hasher`. */
@@ -49,7 +49,7 @@ object AnyValue {
4949
AnyValue(a.asInstanceOf[Ref[T]].value.copy())
5050

5151
def eq(a: AnyRef, b: AnyRef): Boolean =
52-
a.asInstanceOf[Ref[T]].value `eq` b.asInstanceOf[Ref[T]].value
52+
a.asInstanceOf[Ref[T]].value eq b.asInstanceOf[Ref[T]].value
5353

5454
def hashInto(a: AnyRef, hasher: Hasher): Hasher =
5555
a.asInstanceOf[Ref[T]].value.hashInto(hasher)
@@ -62,6 +62,6 @@ given AnyValue is Value:
6262

6363
extension (self: AnyValue)
6464
def copy(): AnyValue = self.copy()
65-
def eq(other: AnyValue): Boolean = self `eq` other
65+
infix def eq(other: AnyValue): Boolean = self eq other
6666
def hashInto(hasher: Hasher): Hasher = self.hashInto(hasher)
6767

tests/pos/hylolib/AnyValueTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class AnyValueTests extends munit.FunSuite:
66

77
test("eq"):
88
val a = AnyValue(1)
9-
assert(a `eq` a)
9+
assert(a eq a)
1010
assert(!(a `neq` a))
1111

1212
val b = AnyValue(2)
13-
assert(!(a `eq` b))
13+
assert(!(a eq b))
1414
assert(a `neq` b)
1515

tests/pos/hylolib/BitArray.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ object BitArray {
300300
new Position(bucket, offsetInBucket)
301301

302302
/** Returns `true` iff `this` and `other` have an equivalent value. */
303-
def eq(other: Position): Boolean =
303+
infix def eq(other: Position): Boolean =
304304
(this.bucket == other.bucket) && (this.offsetInBucket == other.offsetInBucket)
305305

306306
/** Hashes the salient parts of `self` into `hasher`. */
@@ -325,8 +325,8 @@ given BitArray.Position is Value:
325325
def copy(): BitArray.Position =
326326
self.copy()
327327

328-
def eq(other: BitArray.Position): Boolean =
329-
self.eq(other)
328+
infix def eq(other: BitArray.Position): Boolean =
329+
self eq other
330330

331331
def hashInto(hasher: Hasher): Hasher =
332332
self.hashInto(hasher)

tests/pos/hylolib/Collection.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait Collection:
1515

1616
/** Returns `true` iff `self` is empty. */
1717
def isEmpty: Boolean =
18-
startPosition `eq` endPosition
18+
startPosition eq endPosition
1919

2020
/** Returns the number of elements in `self`.
2121
*
@@ -25,7 +25,7 @@ trait Collection:
2525
def count: Int =
2626
val e = endPosition
2727
def loop(p: Position, n: Int): Int =
28-
if p `eq` e then n else loop(self.positionAfter(p), n + 1)
28+
if p eq e then n else loop(self.positionAfter(p), n + 1)
2929
loop(startPosition, 0)
3030

3131
/** Returns the position of `self`'s first element', or `endPosition` if `self` is empty.
@@ -70,12 +70,12 @@ trait Collection:
7070
*/
7171
def isBefore(i: Position, j: Position): Boolean =
7272
val e = self.endPosition
73-
if i `eq` e then false
74-
else if j `eq` e then true
73+
if i eq e then false
74+
else if j eq e then true
7575
else
7676
def recur(n: Position): Boolean =
77-
if n `eq` j then true
78-
else if n `eq` e then false
77+
if n eq j then true
78+
else if n eq e then false
7979
else recur(self.positionAfter(n))
8080
recur(self.positionAfter(i))
8181

@@ -110,7 +110,7 @@ extension [Self: Collection](self: Self)
110110
else
111111
val p = self.startPosition
112112
val q = self.positionAfter(p)
113-
val t = Slice(self, Range(q, self.endPosition, (a, b) => (a `eq` b) || self.isBefore(a, b)))
113+
val t = Slice(self, Range(q, self.endPosition, (a, b) => (a eq b) || self.isBefore(a, b)))
114114
Some((self.at(p), t))
115115

116116
def headAndTail2: Option[(Self.Element, Self.Slice2)] =
@@ -119,7 +119,7 @@ extension [Self: Collection](self: Self)
119119
else
120120
val p = self.startPosition
121121
val q = self.positionAfter(p)
122-
val t = Self.Slice2(self, Range(q, self.endPosition, (a, b) => (a `eq` b) || self.isBefore(a, b)))
122+
val t = Self.Slice2(self, Range(q, self.endPosition, (a, b) => (a eq b) || self.isBefore(a, b)))
123123
Some((self.at(p), t))
124124

125125
/** Applies `combine` on `partialResult` and each element of `self`, in order.
@@ -130,7 +130,7 @@ extension [Self: Collection](self: Self)
130130
def reduce[T](partialResult: T)(combine: (T, Self.Element) => T): T =
131131
val e = self.endPosition
132132
def loop(p: Self.Position, r: T): T =
133-
if p `eq` e then r
133+
if p eq e then r
134134
else loop(self.positionAfter(p), combine(r, self.at(p)))
135135
loop(self.startPosition, partialResult)
136136

@@ -146,7 +146,7 @@ extension [Self: Collection](self: Self)
146146
def forEach(action: Self.Element => Boolean): Boolean =
147147
val e = self.endPosition
148148
def loop(p: Self.Position): Boolean =
149-
if p `eq` e then true
149+
if p eq e then true
150150
else if !action(self.at(p)) then false
151151
else loop(self.positionAfter(p))
152152
loop(self.startPosition)
@@ -194,7 +194,7 @@ extension [Self: Collection](self: Self)
194194
def firstPositionWhere(predicate: Self.Element => Boolean): Option[Self.Position] =
195195
val e = self.endPosition
196196
def loop(p: Self.Position): Option[Self.Position] =
197-
if p `eq` e then None
197+
if p eq e then None
198198
else if predicate(self.at(p)) then Some(p)
199199
else loop(self.positionAfter(p))
200200
loop(self.startPosition)
@@ -243,7 +243,7 @@ extension [Self: Collection](self: Self)
243243
else
244244
val e = self.endPosition
245245
def loop(p: Self.Position, least: Self.Element): Self.Element =
246-
if p `eq` e then
246+
if p eq e then
247247
least
248248
else
249249
val x = self.at(p)
@@ -255,9 +255,9 @@ extension [Self: Collection](self: Self)
255255
/** Returns `true` if `self` contains the same elements as `other`, in the same order. */
256256
def elementsEqual[T: Collection { type Element = Self.Element } ](other: T): Boolean =
257257
def loop(i: Self.Position, j: T.Position): Boolean =
258-
if i `eq` self.endPosition then
259-
j `eq` other.endPosition
260-
else if j `eq` other.endPosition then
258+
if i eq self.endPosition then
259+
j eq other.endPosition
260+
else if j eq other.endPosition then
261261
false
262262
else if self.at(i) `neq` other.at(j)then
263263
false

tests/pos/hylolib/CoreTraits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ trait Value:
1414
def copy(): Self
1515

1616
/** Returns `true` iff `self` and `other` have an equivalent value. */
17-
def eq(other: Self): Boolean
17+
infix def eq(other: Self): Boolean
1818

19-
def neq(other: Self): Boolean = !self.eq(other)
19+
def neq(other: Self): Boolean = !(self eq other)
2020

2121
/** Hashes the salient parts of `self` into `hasher`. */
2222
def hashInto(hasher: Hasher): Hasher

tests/pos/hylolib/HyArray.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ given [T: Value] => HyArray[T] is Value:
165165
def copy(): HyArray[T] =
166166
self.copy()
167167

168-
def eq(other: HyArray[T]): Boolean =
168+
infix def eq(other: HyArray[T]): Boolean =
169169
self.elementsEqual(other)
170170

171171
def hashInto(hasher: Hasher): Hasher =

tests/pos/hylolib/Integers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ given Boolean is Value:
88
// Note: Scala's `Boolean` has value semantics already.
99
self
1010

11-
def eq(other: Boolean): Boolean =
11+
infix def eq(other: Boolean): Boolean =
1212
self == other
1313

1414
def hashInto(hasher: Hasher): Hasher =
@@ -22,7 +22,7 @@ given Int is Value:
2222
// Note: Scala's `Int` has value semantics already.
2323
self
2424

25-
def eq(other: Int): Boolean =
25+
infix def eq(other: Int): Boolean =
2626
self == other
2727

2828
def hashInto(hasher: Hasher): Hasher =
@@ -35,7 +35,7 @@ given Int is Comparable:
3535
def copy(): Int =
3636
self
3737

38-
def eq(other: Int): Boolean =
38+
infix def eq(other: Int): Boolean =
3939
self == other
4040

4141
def hashInto(hasher: Hasher): Hasher =

0 commit comments

Comments
 (0)