1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: v fmt (#7160)

This commit is contained in:
Takahiro Yaota
2020-12-06 23:19:39 +09:00
committed by GitHub
parent 43ff93c25f
commit 0c50f0c9dc
14 changed files with 147 additions and 212 deletions

View File

@@ -1,7 +1,7 @@
module time
fn assert_greater_time(ms int, t1 Time) {
time.sleep_ms(ms)
sleep_ms(ms)
t2 := now()
assert t2.gt(t1)
}
@@ -32,8 +32,7 @@ fn test_now_always_results_in_greater_time() {
}
fn test_time1_should_be_same_as_time2() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -42,8 +41,7 @@ fn test_time1_should_be_same_as_time2() {
second: 3
microsecond: 100
})
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -52,13 +50,11 @@ fn test_time1_should_be_same_as_time2() {
second: 3
microsecond: 100
})
assert t1.eq(t2)
}
fn test_time1_should_not_be_same_as_time2() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -67,9 +63,8 @@ fn test_time1_should_not_be_same_as_time2() {
second: 3
microsecond: 100
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -78,8 +73,7 @@ fn test_time1_should_not_be_same_as_time2() {
second: 3
microsecond: 101
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -88,9 +82,8 @@ fn test_time1_should_not_be_same_as_time2() {
second: 3
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -99,14 +92,12 @@ fn test_time1_should_not_be_same_as_time2() {
second: 4
microsecond: 0
})
assert t1.ne(t2)
assert t3.ne(t4)
}
fn test_time1_should_be_greater_than_time2() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -115,9 +106,8 @@ fn test_time1_should_be_greater_than_time2() {
second: 3
microsecond: 102
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -126,8 +116,7 @@ fn test_time1_should_be_greater_than_time2() {
second: 3
microsecond: 101
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -136,9 +125,8 @@ fn test_time1_should_be_greater_than_time2() {
second: 5
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -147,15 +135,12 @@ fn test_time1_should_be_greater_than_time2() {
second: 4
microsecond: 0
})
assert t1.gt(t2)
assert t3.gt(t4)
}
fn test_time2_should_be_less_than_time1() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -164,9 +149,8 @@ fn test_time2_should_be_less_than_time1() {
second: 3
microsecond: 102
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -175,8 +159,7 @@ fn test_time2_should_be_less_than_time1() {
second: 3
microsecond: 101
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -185,9 +168,8 @@ fn test_time2_should_be_less_than_time1() {
second: 3
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -196,14 +178,12 @@ fn test_time2_should_be_less_than_time1() {
second: 2
microsecond: 0
})
assert t2.lt(t1)
assert t4.lt(t3)
}
fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -212,9 +192,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
second: 3
microsecond: 102
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -223,8 +202,7 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
second: 3
microsecond: 101
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -233,9 +211,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
second: 5
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -244,14 +221,12 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_gt() {
second: 4
microsecond: 0
})
assert t1.ge(t2)
assert t3.ge(t4)
}
fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -260,9 +235,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
second: 3
microsecond: 100
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -271,8 +245,7 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
second: 3
microsecond: 100
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -281,9 +254,8 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
second: 3
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -292,14 +264,12 @@ fn test_time1_should_be_greater_or_equal_to_time2_when_eq() {
second: 3
microsecond: 0
})
assert t1.ge(t2)
assert t3.ge(t4)
}
fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -308,9 +278,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
second: 3
microsecond: 100
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -319,8 +288,7 @@ fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
second: 3
microsecond: 101
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -329,9 +297,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
second: 3
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -340,14 +307,12 @@ fn test_time1_should_be_less_or_equal_to_time2_when_lt() {
second: 4
microsecond: 0
})
assert t1.le(t2)
assert t3.le(t4)
}
fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -356,9 +321,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
second: 3
microsecond: 100
})
// Difference is one microsecond
t2 := new_time( Time {
t2 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -367,8 +331,7 @@ fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
second: 3
microsecond: 100
})
t3 := new_time( Time {
t3 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -377,9 +340,8 @@ fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
second: 3
microsecond: 0
})
// Difference is one second
t4 := new_time( Time {
t4 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -388,13 +350,12 @@ fn test_time1_should_be_less_or_equal_to_time2_when_eq() {
second: 3
microsecond: 0
})
assert t1.le(t2)
assert t3.le(t4)
}
fn test_time2_copied_from_time1_should_be_equal() {
t1 := new_time( Time {
t1 := new_time(Time{
year: 2000
month: 5
day: 10
@@ -404,6 +365,5 @@ fn test_time2_copied_from_time1_should_be_equal() {
microsecond: 100
})
t2 := new_time(t1)
assert t2.eq(t1)
}