|
| 1 | +R1381:0[5]{:[1]<11>commands.py:[0]<2>py}<11>commands.py<1326>from cc import commands |
| 2 | + |
| 3 | + |
| 4 | +class AnyInstanceOf: |
| 5 | + def __init__(self, cls): |
| 6 | + self.c = cls |
| 7 | + |
| 8 | + def __eq__(self, other): |
| 9 | + return isinstance(other, self.c) |
| 10 | + |
| 11 | + |
| 12 | +print('Run this test on command computer') |
| 13 | + |
| 14 | +xyz = commands.getBlockPosition() |
| 15 | +assert xyz == ( |
| 16 | + AnyInstanceOf(int), |
| 17 | + AnyInstanceOf(int), |
| 18 | + AnyInstanceOf(int), |
| 19 | +) |
| 20 | + |
| 21 | +expected_binfo = { |
| 22 | + 'state': { |
| 23 | + 'state': AnyInstanceOf(str), |
| 24 | + 'facing': AnyInstanceOf(str), |
| 25 | + }, |
| 26 | + 'name': 'computercraft:computer_command', |
| 27 | + 'nbt': { |
| 28 | + 'x': xyz[0], |
| 29 | + 'y': xyz[1], |
| 30 | + 'z': xyz[2], |
| 31 | + 'ForgeCaps': {}, |
| 32 | + 'ComputerId': AnyInstanceOf(int), |
| 33 | + 'id': 'computercraft:computer_command', |
| 34 | + 'On': 1, |
| 35 | + }, |
| 36 | + 'tags': {'computercraft:computer': True}, |
| 37 | +} |
| 38 | + |
| 39 | +assert commands.getBlockInfo(*xyz) == expected_binfo |
| 40 | +assert commands.getBlockInfos(*xyz, *xyz) == [expected_binfo] |
| 41 | + |
| 42 | +cmdlist = commands.list() |
| 43 | + |
| 44 | +assert len(cmdlist) > 0 |
| 45 | +for c in cmdlist: |
| 46 | + assert isinstance(c, str) |
| 47 | + |
| 48 | +assert commands.exec('say Hello!') == (True, [], AnyInstanceOf(int)) |
| 49 | + |
| 50 | +d = commands.exec('tp hajejndlasksdkelefsns fjeklaskslekffjslas') |
| 51 | +assert d[0] is False |
| 52 | + |
| 53 | +d = commands.exec('difficulty') |
| 54 | +assert d[0] is True |
| 55 | +assert len(d[1]) == 1 |
| 56 | +assert d[1][0].startswith('The difficulty is ') |
| 57 | +assert isinstance(d[2], int) |
| 58 | + |
| 59 | +print('Test finished successfully') |
| 60 | +S65:T<1>1<13>io.write(...){:[1]<33>Run this test on command computer} |
| 61 | +R15:T<1>1<7>{:[1]T} |
| 62 | +S32:T<1>1<13>io.write(...){:[1]<1> |
| 63 | +} |
| 64 | +R15:T<1>1<7>{:[1]T} |
| 65 | +S40:T<1>1<29>G:commands:M:getBlockPosition{} |
| 66 | +R42:T<1>1<33>{:[1]T:[2][-12]:[3][70]:[4][-19]} |
| 67 | +S62:T<1>1<25>G:commands:M:getBlockInfo{:[1][-12]:[2][70]:[3][-19]} |
| 68 | +R272:T<1>1<262>{:[1]T:[2]{:<5>state{:<5>state<8>blinking:<6>facing<5>south}:<3>nbt{:<1>y[70]:<1>x[-12]:<10>ComputerId[5]:<9>ForgeCaps{}:<2>id<30>computercraft:computer_command:<2>On[1]:<1>z[-19]}:<4>name<30>computercraft:computer_command:<4>tags{:<22>computercraft:computerT}}} |
| 69 | +S89:T<1>1<26>G:commands:M:getBlockInfos{:[1][-12]:[2][70]:[3][-19]:[4][-12]:[5][70]:[6][-19]} |
| 70 | +R272:T<1>1<262>{:[1]T:[2]{:[1]{:<5>state{:<5>state<2>on:<6>facing<5>south}:<3>nbt{:<1>y[70]:<1>x[-12]:<10>ComputerId[5]:<9>ForgeCaps{}:<2>id<30>computercraft:computer_command:<2>On[1]:<1>z[-19]}:<4>name<30>computercraft:computer_command:<4>tags{:<22>computercraft:computerT}}}} |
| 71 | +S28:T<1>1<17>G:commands:M:list{} |
| 72 | +R1021:T<1>1<1010>{:[1]T:[2]{:[1]<11>advancement:[2]<9>attribute:[3]<7>execute:[4]<7>bossbar:[5]<5>clear:[6]<5>clone:[7]<6>damage:[8]<4>data:[9]<8>datapack:[10]<5>debug:[11]<15>defaultgamemode:[12]<10>difficulty:[13]<6>effect:[14]<2>me:[15]<7>enchant:[16]<10>experience:[17]<2>xp:[18]<4>fill:[19]<9>fillbiome:[20]<9>forceload:[21]<8>function:[22]<8>gamemode:[23]<8>gamerule:[24]<4>give:[25]<4>help:[26]<4>item:[27]<4>kick:[28]<4>kill:[29]<4>list:[30]<6>locate:[31]<4>loot:[32]<3>msg:[33]<4>tell:[34]<1>w:[35]<8>particle:[36]<5>place:[37]<9>playsound:[38]<6>reload:[39]<6>recipe:[40]<6>return:[41]<4>ride:[42]<3>say:[43]<8>schedule:[44]<10>scoreboard:[45]<4>seed:[46]<8>setblock:[47]<10>spawnpoint:[48]<13>setworldspawn:[49]<8>spectate:[50]<13>spreadplayers:[51]<9>stopsound:[52]<6>summon:[53]<3>tag:[54]<4>team:[55]<7>teammsg:[56]<2>tm:[57]<8>teleport:[58]<2>tp:[59]<7>tellraw:[60]<4>time:[61]<5>title:[62]<7>trigger:[63]<7>weather:[64]<11>worldborder:[65]<3>jfr:[66]<7>publish:[67]<13>computercraft:[68]<5>forge:[69]<6>config}} |
| 73 | +S46:T<1>1<17>G:commands:M:exec{:[1]<10>say Hello!} |
| 74 | +R34:T<1>1<25>{:[1]T:[2]T:[3]{}:[4][1]} |
| 75 | +S80:T<1>1<17>G:commands:M:exec{:[1]<44>tp hajejndlasksdkelefsns fjeklaskslekffjslas} |
| 76 | +R134:T<1>1<124>{:[1]T:[2]F:[3]{:[1]<30>Incorrect argument for command:[2]<53>tp hajejndlasksdkelefsns fjeklaskslekffjslas<--[HERE]}:[4][0]} |
| 77 | +S46:T<1>1<17>G:commands:M:exec{:[1]<10>difficulty} |
| 78 | +R66:T<1>1<57>{:[1]T:[2]T:[3]{:[1]<24>The difficulty is Normal}:[4][2]} |
| 79 | +S58:T<1>1<13>io.write(...){:[1]<26>Test finished successfully} |
| 80 | +R15:T<1>1<7>{:[1]T} |
| 81 | +S32:T<1>1<13>io.write(...){:[1]<1> |
| 82 | +} |
| 83 | +R15:T<1>1<7>{:[1]T} |
| 84 | +S2:CN |
0 commit comments