mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: use operator overloading for >=
and <=
(#8009)
This commit is contained in:
parent
2a75a30be5
commit
8f4238e76a
@ -24,9 +24,9 @@ pub fn (t1 Time) < (t2 Time) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// le returns true if provided time is less or equal to time
|
// operator `<=` returns true if provided time is less or equal to time
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (t1 Time) le(t2 Time) bool {
|
pub fn (t1 Time) <= (t2 Time) bool {
|
||||||
return t1 < t2 || t1 == t2
|
return t1 < t2 || t1 == t2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ pub fn (t1 Time) > (t2 Time) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// ge returns true if provided time is greater or equal to time
|
// operator `>=` returns true if provided time is greater or equal to time
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (t1 Time) ge(t2 Time) bool {
|
pub fn (t1 Time) >= (t2 Time) bool {
|
||||||
return t1 > t2 || t1 == t2
|
return t1 > t2 || t1 == t2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,8 +221,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
|
|||||||
second: 4
|
second: 4
|
||||||
microsecond: 0
|
microsecond: 0
|
||||||
})
|
})
|
||||||
assert t1.ge(t2)
|
assert t1 >= t2
|
||||||
assert t3.ge(t4)
|
assert t3 >= t4
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
|
fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
|
||||||
@ -264,8 +264,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
|
|||||||
second: 3
|
second: 3
|
||||||
microsecond: 0
|
microsecond: 0
|
||||||
})
|
})
|
||||||
assert t1.ge(t2)
|
assert t1 >= t2
|
||||||
assert t3.ge(t4)
|
assert t3 >= t4
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
|
fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
|
||||||
@ -307,8 +307,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
|
|||||||
second: 4
|
second: 4
|
||||||
microsecond: 0
|
microsecond: 0
|
||||||
})
|
})
|
||||||
assert t1.le(t2)
|
assert t1 <= t2
|
||||||
assert t3.le(t4)
|
assert t3 <= t4
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
|
fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
|
||||||
@ -350,8 +350,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
|
|||||||
second: 3
|
second: 3
|
||||||
microsecond: 0
|
microsecond: 0
|
||||||
})
|
})
|
||||||
assert t1.le(t2)
|
assert t1 <= t2
|
||||||
assert t3.le(t4)
|
assert t3 <= t4
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_time2_copied_from_time1_should_be_equal() {
|
fn test_time2_copied_from_time1_should_be_equal() {
|
||||||
|
Loading…
Reference in New Issue
Block a user