Skip to content

Commit 54625a6

Browse files
committed
Add tests for CC:T 1.119
1 parent f1e4a14 commit 54625a6

45 files changed

Lines changed: 7456 additions & 14 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/TDESC_CC.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
`wget http://127.0.0.1:8000 py`
22

3-
# helloworld
3+
# helloworld.txt
44

55
`py helloworld.py 42 abc`
66

7-
# term
7+
# shutdown.txt
88

9-
`py term.py`
9+
`py shutdown.py`
10+
11+
# shutdown_reboot.txt
12+
13+
`py shutdown.py reboot`

tests/cc_programs/commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ def __eq__(self, other):
2828
'x': xyz[0],
2929
'y': xyz[1],
3030
'z': xyz[2],
31-
'ForgeCaps': {},
3231
'ComputerId': AnyInstanceOf(int),
3332
'id': 'computercraft:computer_command',
3433
'On': 1,
3534
},
36-
'tags': {'computercraft:computer': True},
35+
'tags': {
36+
'computercraft:computer': True,
37+
'minecraft:wither_immune': True,
38+
},
3739
}
3840

3941
assert commands.getBlockInfo(*xyz) == expected_binfo

tests/cc_programs/disk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def assert_raises(etype, message=None):
4343
assert disk.getLabel(s) is None
4444
assert disk.getID(s) is None
4545
assert disk.hasAudio(s) is False
46-
assert disk.getAudioTitle(s) is None
46+
assert disk.getAudioTitle(s) is False
4747
assert disk.playAudio(s) is None
4848
assert disk.stopAudio(s) is None
4949
assert disk.eject(s) is None

tests/cc_programs/fs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __eq__(self, other):
6565
assert fs.isDriveRoot('rom') is True
6666
assert fs.isDriveRoot('tdir') is False
6767
assert fs.isDriveRoot('tfile') is False
68-
assert fs.isDriveRoot('doesnotexist') is True # wtf?
68+
assert fs.isDriveRoot('doesnotexist') is False
6969

7070
assert fs.getName('a/b/c/d') == 'd'
7171
assert fs.getName('a/b/c/') == 'c'
@@ -86,8 +86,8 @@ def __eq__(self, other):
8686
assert fs.getDir('/') == '..'
8787
assert fs.getDir('///') == '..'
8888
assert fs.getDir('.') == '..'
89-
assert fs.getDir('..') == ''
90-
assert fs.getDir('../../..') == '../..'
89+
assert fs.getDir('..') == '../..'
90+
assert fs.getDir('../../..') == '../../../..'
9191

9292
assert fs.combine('a', 'b') == 'a/b'
9393
assert fs.combine('a/', 'b') == 'a/b'
@@ -175,8 +175,8 @@ def __eq__(self, other):
175175
assert f.readLine() == 'line'
176176
assert f.read(1) is None
177177
assert f.readLine() is None
178-
assert f.readAll() is None
179-
assert f.readAll() is None
178+
assert f.readAll() == ''
179+
assert f.readAll() == ''
180180
assert fs.getSize('tdir/banana') == 9
181181
with fs.open('tdir/banana', 'a') as f:
182182
assert f.write('x') is None

tests/cc_programs/peripheral_commandblock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
side = 'left'
66

7+
print('This test requires server config:')
8+
print('peripheral.command_block_enabled=true')
79
_lib.step(f'Attach command block at {side} side of computer')
810

911
m = peripheral.wrap(side)

tests/cc_programs/peripheral_disk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
assert d.getDiskLabel() is None
1717
assert d.getDiskID() is None
1818
assert d.hasAudio() is False
19-
assert d.getAudioTitle() is None
19+
assert d.getAudioTitle() is False
2020
assert d.playAudio() is None
2121
assert d.stopAudio() is None
2222
assert d.ejectDisk() is None

tests/cc_programs/peripheral_modem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def _recv():
4444
f'Attach wired modem to {side} side\n'
4545
f'Place another computer with wired modem on {side} side\n'
4646
'Connect modems\n'
47-
'On another computer start py modem_server.py'
47+
'On another computer start peripheral_modem_server.lua'
4848
)
4949
do_test()
5050
_lib.step(
5151
'Disconnect and remove wired modems\n'
5252
'Attach wireless modems\n'
53-
'Restart modem_server.py on another computer'
53+
'Restart peripheral_modem_server.lua on another computer'
5454
)
5555
do_test()
5656
print('Test finished successfully')
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
side = 'back'
2+
m = peripheral.wrap(side)
3+
channel = 5
4+
m.close(channel)
5+
m.open(channel)
6+
while true do
7+
local event, evside, evchannel, reply, msg, dist = os.pullEvent('modem_message')
8+
if eside == side or evchannel == channel then
9+
print('reply:', reply, 'msg:', msg, 'dist:', dist)
10+
if msg == 'stop' then break end
11+
m.transmit(reply, channel, msg)
12+
end
13+
end
14+
m.close(channel)

tests/cc_programs/window.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@
3030
win.reposition(21, 5)
3131
win.reposition(27, 5)
3232

33+
os.sleep(1)
34+
35+
term.clear()
36+
print()
3337
print('Test finished successfully')
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
R637:0[5]{:[1]<9>colors.py:[0]<2>py}<9>colors.py<589>from cc import colors
2+
3+
cs = colors.combine(
4+
colors.orange,
5+
colors.cyan,
6+
colors.pink,
7+
colors.brown,
8+
)
9+
assert isinstance(cs, int)
10+
cs = colors.subtract(cs, colors.brown, colors.green)
11+
assert isinstance(cs, int)
12+
assert cs == colors.combine(
13+
colors.orange,
14+
colors.cyan,
15+
colors.pink,
16+
)
17+
assert colors.test(cs, colors.red) is False
18+
assert colors.test(cs, colors.cyan) is True
19+
20+
assert colors.packRGB(0.7, 0.2, 0.6) == 0xb23399
21+
r, g, b = colors.unpackRGB(0xb23399)
22+
assert 0.68 < r < 0.72
23+
assert 0.18 < g < 0.22
24+
assert 0.58 < b < 0.62
25+
26+
print('Test finished successfully')
27+
28+
S63:T<1>1<18>G:colors:M:combine{:[1][2]:[2][512]:[3][64]:[4][4096]}
29+
R26:T<1>1<17>{:[1]T:[2][4674]}
30+
S60:T<1>1<19>G:colors:M:subtract{:[1][4674]:[2][4096]:[3][8192]}
31+
R25:T<1>1<16>{:[1]T:[2][578]}
32+
S53:T<1>1<18>G:colors:M:combine{:[1][2]:[2][512]:[3][64]}
33+
R25:T<1>1<16>{:[1]T:[2][578]}
34+
S46:T<1>1<15>G:colors:M:test{:[1][578]:[2][16384]}
35+
R21:T<1>1<12>{:[1]T:[2]F}
36+
S44:T<1>1<15>G:colors:M:test{:[1][578]:[2][512]}
37+
R21:T<1>1<12>{:[1]T:[2]T}
38+
S56:T<1>1<18>G:colors:M:packRGB{:[1][0.7]:[2][0.2]:[3][0.6]}
39+
R30:T<1>1<21>{:[1]T:[2][11678617]}
40+
S45:T<1>1<20>G:colors:M:unpackRGB{:[1][11678617]}
41+
R59:T<1>1<50>{:[1]T:[2][0.69803921568627447]:[3][0.2]:[4][0.6]}
42+
S58:T<1>1<13>io.write(...){:[1]<26>Test finished successfully}
43+
R15:T<1>1<7>{:[1]T}
44+
S32:T<1>1<13>io.write(...){:[1]<1>
45+
}
46+
R15:T<1>1<7>{:[1]T}
47+
S2:CN
48+
R1:D

0 commit comments

Comments
 (0)