Skip to content

Commit de5465e

Browse files
committed
Use print in tests, not log
1 parent 74ea78f commit de5465e

File tree

6 files changed

+45
-51
lines changed

6 files changed

+45
-51
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import lightbug.protocol as protocol
22
import lightbug.messages show *
3-
import log
43

54
main:
65
testConstructor
@@ -10,4 +9,4 @@ testConstructor:
109
// http://docs-next.lightbug.io/devices/api/parse?bytes=03%2C%200x4f%2C%200x00%2C%200x0f%2C%200x00%2C%200x02%2C%200x00%2C%200x01%2C%200x02%2C%200x04%2C%200x1b%2C%200x01%2C%200x00%2C%200x00%2C%200x08%2C%200x56%2C%200x99%2C%200x93%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%200x0b%2C%200x00%2C%200x01%2C%200x02%2C%200x03%2C%200x04%2C%200x05%2C%200x06%2C%200x07%2C%200x08%2C%200x09%2C%200x0a%2C%200x0b%2C%200x08%2C%200x78%2C%200x87%2C%200xad%2C%200x0c%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%200x04%2C%200xd8%2C%200xa7%2C%200xad%2C%200x1e%2C%200x04%2C%200x5f%2C%200x33%2C%200x7c%2C%200xfe%2C%200x04%2C%200xf2%2C%200xe8%2C%200x01%2C%200x00%2C%200x02%2C%200x69%2C%200x03%2C%200x02%2C%200x17%2C%200x70%2C%200x02%2C%200x02%2C%200x00%2C%200x01%2C%200x1b%2C%200x01%2C%200x00%2C%200x01%2C%200x03%2C%200x01%2C%200x01%2C%200xf6%2C%200x75
1110
b := #[0X0B, 0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X06, 0X07, 0X08, 0X09, 0X0A, 0X0B, 0X08, 0X78, 0X87, 0XAD, 0X0C, 0X00, 0X00, 0X00, 0X00, 0X04, 0XD8, 0XA7, 0XAD, 0X1E, 0X04, 0X5F, 0X33, 0X7C, 0XFE, 0X04, 0XF2, 0XE8, 0X01, 0X00, 0X02, 0X69, 0X03, 0X02, 0X17, 0X70, 0X02, 0X02, 0X00, 0X01, 0X1B, 0X01, 0X00, 0X01, 0X03, 0X01, 0X01]
1211
LastPosition.from-data (protocol.Data.from-bytes b)
13-
log.info "✅ Passed creating LastPositionData from Data"
12+
print "✅ Passed creating LastPositionData from Data"

tests/protocol/Data.test.toit

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import lightbug.protocol show *
2-
import log
32

43
main:
54
addAndget-data
@@ -11,61 +10,61 @@ from-bytes:
1110
// no data fileds
1211
d := Data.from-bytes #[0x00, 0x00]
1312
if d.data-field-count != 0:
14-
log.error "❌ Failed getting data-field-count of empty data, got: " + d.data-field-count.stringify
13+
print "❌ Failed getting data-field-count of empty data, got: " + d.data-field-count.stringify
1514
else:
16-
log.info "✅ Passed getting data-field-count of empty data"
15+
print "✅ Passed getting data-field-count of empty data"
1716

1817
// a single uint8 of type 1 value 2
1918
d = Data.from-bytes #[0x01, 0x00, 0x01, 0x01, 0x02]
2019
if d.data-field-count != 1:
21-
log.error "❌ Failed getting data-field-count of single data field, got: " + d.data-field-count.stringify
20+
print "❌ Failed getting data-field-count of single data field, got: " + d.data-field-count.stringify
2221
else:
23-
log.info "✅ Passed getting data-field-count of single data field"
22+
print "✅ Passed getting data-field-count of single data field"
2423

2524
// uint8 of type 1 value 2, and 2 bytes of type 5, value 8 8
2625
d = Data.from-bytes #[0x02, 0x00, 0x01, 0x05, 0x01, 0x02, 0x02, 0x08, 0x08]
2726
if d.data-field-count != 2:
28-
log.error "❌ Failed getting data-field-count of 2 data fields, got: " + d.data-field-count.stringify
27+
print "❌ Failed getting data-field-count of 2 data fields, got: " + d.data-field-count.stringify
2928
else:
30-
log.info "✅ Passed getting data-field-count of 2 data fields"
29+
print "✅ Passed getting data-field-count of 2 data fields"
3130

3231
from-list:
3332
// no data fileds
3433
d := Data.from-list [0x00, 0x00]
3534
if d.data-field-count != 0:
36-
log.error "❌ LIST Failed getting data-field-count of empty data, got: " + d.data-field-count.stringify
35+
print "❌ LIST Failed getting data-field-count of empty data, got: " + d.data-field-count.stringify
3736
else:
38-
log.info "✅ LIST Passed getting data-field-count of empty data"
37+
print "✅ LIST Passed getting data-field-count of empty data"
3938

4039
// a single uint8 of type 1 value 2
4140
d = Data.from-list [0x01, 0x00, 0x01, 0x01, 0x02]
4241
if d.data-field-count != 1:
43-
log.error "❌ LIST Failed getting data-field-count of single data field, got: " + d.data-field-count.stringify
42+
print "❌ LIST Failed getting data-field-count of single data field, got: " + d.data-field-count.stringify
4443
else:
45-
log.info "✅ LIST Passed getting data-field-count of single data field"
44+
print "✅ LIST Passed getting data-field-count of single data field"
4645

4746
// uint8 of type 1 value 2, and 2 bytes of type 5, value 8 8
4847
d = Data.from-list [0x02, 0x00, 0x01, 0x05, 0x01, 0x02, 0x02, 0x08, 0x08]
4948
if d.data-field-count != 2:
50-
log.error "❌ LIST Failed getting data-field-count of 2 data fields, got: " + d.data-field-count.stringify
49+
print "❌ LIST Failed getting data-field-count of 2 data fields, got: " + d.data-field-count.stringify
5150
else:
52-
log.info "✅ LIST Passed getting data-field-count of 2 data fields"
51+
print "✅ LIST Passed getting data-field-count of 2 data fields"
5352

5453
toBytes:
5554
d := Data
5655
d.add-data-uint8 1 6
5756
b := d.bytes-for-protocol
5857
if b != #[0x01, 0x00, 0x01, 0x01, 0x06]:
59-
log.error "❌ Failed toBytes single uint8, got: $b"
58+
print "❌ Failed toBytes single uint8, got: $b"
6059
else:
61-
log.info "✅ Passed toBytes single uint8"
60+
print "✅ Passed toBytes single uint8"
6261

6362
d.add-data 5 #[8, 8]
6463
b = d.bytes-for-protocol
6564
if b != #[0x02, 0x00, 0x01, 0x05, 0x01, 0x06, 0x02, 0x08, 0x08]:
66-
log.error "❌ Failed toBytes 2 data fields, got: $b"
65+
print "❌ Failed toBytes 2 data fields, got: $b"
6766
else:
68-
log.info "✅ Passed toBytes 2 data fields"
67+
print "✅ Passed toBytes 2 data fields"
6968

7069
addAndget-data:
7170
d := Data
@@ -76,25 +75,25 @@ addAndget-data:
7675
// Test uint32
7776
d.add-data-uint32 1 290
7877
if (d.get-data 1) != #[0x22, 0x01, 0x00, 0x00]:
79-
log.error "❌ Failed uint32 byte representation"
78+
print "❌ Failed uint32 byte representation"
8079
else:
81-
log.info "✅ Passed uint32 byte representation"
80+
print "✅ Passed uint32 byte representation"
8281

8382
// Test int32
8483
d.add-data-int32 2 290
8584
if (d.get-data 2) != #[0x22, 0x01, 0x00, 0x00]:
86-
log.error "❌ Failed int32 byte representation"
85+
print "❌ Failed int32 byte representation"
8786
else:
88-
log.info "✅ Passed int32 byte representation"
87+
print "✅ Passed int32 byte representation"
8988

9089
// Test float
9190
d.add-data-float32 3 3.1415927
9291
got := d.get-data 3
9392
expect := #[0xdb, 0x0f, 0x49, 0x40]
9493
if got != expect:
95-
log.error "❌ Failed float byte representation. Expected: $expect, got: $got"
94+
print "❌ Failed float byte representation. Expected: $expect, got: $got"
9695
else:
97-
log.info "✅ Passed float byte representation"
96+
print "✅ Passed float byte representation"
9897

9998
////////////////
10099
// Round trips
@@ -103,49 +102,49 @@ addAndget-data:
103102
// Test uint32 roundtrip
104103
d.add-data-uint32 4 290
105104
if (d.get-data-uint32 4) != 290:
106-
log.error "❌ Failed uint32 roundtrip"
105+
print "❌ Failed uint32 roundtrip"
107106
else:
108-
log.info "✅ Passed uint32 roundtrip"
107+
print "✅ Passed uint32 roundtrip"
109108

110109
// Test int32 roundtrip
111110
d.add-data-int32 5 -290
112111
if (d.get-data-int32 5) != -290:
113-
log.error "❌ Failed int32 roundtrip"
112+
print "❌ Failed int32 roundtrip"
114113
else:
115-
log.info "✅ Passed int32 roundtrip"
114+
print "✅ Passed int32 roundtrip"
116115

117116
// Float roundtrip
118117
expected := 3.1400001049041748047
119118
d.add-data-float32 6 expected
120119
gotFloat := d.get-data-float32 6
121120
if gotFloat != expected:
122-
log.error "❌ Failed float roundtrip. Expected: $expected, got: $gotFloat"
121+
print "❌ Failed float roundtrip. Expected: $expected, got: $gotFloat"
123122
else:
124-
log.info "✅ Passed float roundtrip"
123+
print "✅ Passed float roundtrip"
125124

126125
// list uint16 roundtrip
127126
expectedList := [1, 2, 3]
128127
d.add-data-list-uint16 7 expectedList
129128
gotList := d.get-data-list-uint16 7
130129
if gotList != expectedList:
131-
log.error "❌ Failed list uint16 roundtrip. Expected: $expectedList, got: $gotList"
130+
print "❌ Failed list uint16 roundtrip. Expected: $expectedList, got: $gotList"
132131
else:
133-
log.info "✅ Passed list uint16 roundtrip"
132+
print "✅ Passed list uint16 roundtrip"
134133

135134
// list uint32 roundtrip
136135
expectedListUint32 := [100000, 200000, 300000]
137136
d.add-data-list-uint32 8 expectedListUint32
138137
gotListUint32 := d.get-data-list-uint32 8
139138
if gotListUint32 != expectedListUint32:
140-
log.error "❌ Failed list uint32 roundtrip. Expected: $expectedListUint32, got: $gotListUint32"
139+
print "❌ Failed list uint32 roundtrip. Expected: $expectedListUint32, got: $gotListUint32"
141140
else:
142-
log.info "✅ Passed list uint32 roundtrip"
141+
print "✅ Passed list uint32 roundtrip"
143142

144143
// list int32 pairs roundtrip
145144
expectedListInt32Pairs := [[1, 2], [3, 4], [5, 6]]
146145
d.add-data-list-int32-pairs 9 expectedListInt32Pairs
147146
gotListInt32Pairs := d.get-data-list-int32-pairs 9
148147
if gotListInt32Pairs != expectedListInt32Pairs:
149-
log.error "❌ Failed list int32 pairs roundtrip. Expected: $expectedListInt32Pairs, got: $gotListInt32Pairs"
148+
print "❌ Failed list int32 pairs roundtrip. Expected: $expectedListInt32Pairs, got: $gotListInt32Pairs"
150149
else:
151-
log.info "✅ Passed list int32 pairs roundtrip"
150+
print "✅ Passed list int32 pairs roundtrip"

tests/protocol/DataField.test.toit

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import lightbug.protocol show *
2-
import log
32

43
main:
54
name := "bytes-for-protocol: no bytes still has length"
65
d := DataField
76
got := d.bytes-for-protocol
87
want := #[0x00]
98
if got != want:
10-
log.error "❌ " + name + ": Wanted " + want.stringify + " got " + got.stringify
9+
print "❌ " + name + ": Wanted " + want.stringify + " got " + got.stringify
1110
else:
12-
log.info "✅ " + name + ": Got " + got.stringify
11+
print "✅ " + name + ": Got " + got.stringify
1312

1413
name = "bytes-for-protocol: one byte"
1514
d = DataField #[0x50]
1615
got = d.bytes-for-protocol
1716
want = #[0x01, 0x50]
1817
if got != want:
19-
log.error "❌ " + name + ": Wanted " + want.stringify + " got " + got.stringify
18+
print "❌ " + name + ": Wanted " + want.stringify + " got " + got.stringify
2019
else:
21-
log.info "✅ " + name + ": Got " + got.stringify
20+
print "✅ " + name + ": Got " + got.stringify

tests/protocol/Message.test.toit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import lightbug.protocol show *
2-
import log
32

43
main:
54
bl := [0x03, 0x28, 0x00, 0x05, 0x00, 0x04, 0x00, 0x03, 0x04, 0x01, 0x02, 0x04, 0xe0, 0x7e, 0x7e, 0x87, 0x01, 0x00, 0x04, 0x58, 0x00, 0x00, 0x00, 0x08, 0x56, 0x99, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02, 0x0b, 0x00, 0xc9, 0x35]
65
m := Message.from-list bl
76
// If we didnt error, count it as passed :)
8-
log.info "✅ Passed from-list (as no error)"
7+
print "✅ Passed from-list (as no error)"

tests/protocol/constants.test.toit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import lightbug.protocol as lbp
2-
import log
32

43
main:
54
// just tests that the constants can easily be used from the package
6-
log.info "✅ Passed using constants from the package: " + lbp.Header.TYPE-CLIENT-ID.stringify
5+
print "✅ Passed using constants from the package: " + lbp.Header.TYPE-CLIENT-ID.stringify

tests/util/idgen.test.toit

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import lightbug.util.idgen
2-
import log
32

43
main:
54
sequential
@@ -11,15 +10,15 @@ sequential:
1110
expectedI.do:
1211
i := g.next
1312
if i != it:
14-
log.info "❌ idgen sequential Wanted $it got $i"
13+
print "❌ idgen sequential Wanted $it got $i"
1514
else:
16-
log.info "✅ idgen sequential Got $i"
15+
print "✅ idgen sequential Got $i"
1716

1817
random:
1918
g := idgen.RandomIdGenerator --lowerBound=1 --upperBound=3
2019
for i := 0; i < 10; i++:
2120
it := g.next
2221
if it < 1 or it > 3:
23-
log.error "❌ idgen random Out of bounds $it"
22+
print "❌ idgen random Out of bounds $it"
2423
else:
25-
log.info "✅ idgen random Got $it (in bounds)"
24+
print "✅ idgen random Got $it (in bounds)"

0 commit comments

Comments
 (0)