@@ -1417,10 +1417,6 @@ async def test_commandblock_peripheral(api):
14171417 await api .print ('Test finished successfully' )
14181418
14191419
1420- async def test_turtle_peripheral (api ):
1421- raise NotImplementedError
1422-
1423-
14241420async def test_modem_wrap (api ):
14251421 side = 'back'
14261422
@@ -1460,3 +1456,88 @@ async def test_modem_wrap(api):
14601456
14611457 await api .print ('You must have heard levelup sound' )
14621458 await api .print ('Test finished successfully' )
1459+
1460+
1461+ async def test_turtle_peripheral (api ):
1462+ raise NotImplementedError
1463+
1464+
1465+ async def test_textutils (api ):
1466+ assert await api .textutils .slowWrite ('write ' ) is None
1467+ assert await api .textutils .slowWrite ('write ' , 5 ) is None
1468+ assert await api .textutils .slowPrint ('print' ) is None
1469+ assert await api .textutils .slowPrint ('print' , 5 ) is None
1470+
1471+ assert await api .textutils .formatTime (0 ) == '0:00 AM'
1472+ assert await api .textutils .formatTime (0 , True ) == '0:00'
1473+
1474+ table = [
1475+ api .colors .red ,
1476+ ['Planet' , 'Distance' , 'Mass' ],
1477+ api .colors .gray ,
1478+ ['Mercury' , '0.387' , '0.055' ],
1479+ api .colors .lightGray ,
1480+ ['Venus' , '0.723' , '0.815' ],
1481+ api .colors .green ,
1482+ ['Earth' , '1.000' , '1.000' ],
1483+ api .colors .red ,
1484+ ['Mars' , '1.524' , '0.107' ],
1485+ api .colors .orange ,
1486+ ['Jupiter' , '5.203' , '318' ],
1487+ api .colors .yellow ,
1488+ ['Saturn' , '9.537' , '95' ],
1489+ api .colors .cyan ,
1490+ ['Uranus' , '19.191' , '14.5' ],
1491+ api .colors .blue ,
1492+ ['Neptune' , '30.069' , '17' ],
1493+ api .colors .white ,
1494+ ]
1495+
1496+ assert await api .textutils .tabulate (* table ) is None
1497+
1498+ lines = await api .textutils .pagedPrint ('''
1499+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
1500+ Suspendisse feugiat diam et velit aliquam, nec porttitor eros facilisis.
1501+ Nulla facilisi.
1502+ Sed eget dui vel tellus aliquam fermentum.
1503+ Aliquam sed lorem congue, dignissim nulla in, porta diam.
1504+ Aliquam erat volutpat.
1505+ ''' .strip ())
1506+ assert isinstance (lines , int )
1507+ assert lines > 0
1508+
1509+ assert await api .textutils .pagedTabulate (* table [:- 1 ], * table [2 :- 1 ], * table [2 :]) is None
1510+
1511+ assert api .textutils .complete ('co' , ['command' , 'row' , 'column' ]) == [
1512+ 'mmand' , 'lumn' ]
1513+
1514+ await api .print ('Test finished successfully' )
1515+
1516+
1517+ async def test_pocket (api ):
1518+ assert await api .peripheral .isPresent ('back' ) is False
1519+
1520+ from computercraft .subapis .pocket import PocketAPI
1521+ tbl = await get_object_table (api , 'pocket' )
1522+ assert get_class_table (PocketAPI ) == tbl
1523+
1524+ await step (api , 'Clean inventory from any pocket upgrades' )
1525+
1526+ with assert_raises (LuaException ):
1527+ await api .pocket .equipBack ()
1528+ with assert_raises (LuaException ):
1529+ await api .pocket .unequipBack ()
1530+ assert await api .peripheral .isPresent ('back' ) is False
1531+
1532+ await step (api , 'Put any pocket upgrade to inventory' )
1533+
1534+ assert await api .pocket .equipBack () is None
1535+ assert await api .peripheral .isPresent ('back' ) is True
1536+
1537+ assert await api .pocket .unequipBack () is None
1538+ assert await api .peripheral .isPresent ('back' ) is False
1539+
1540+ await api .print ('Test finished successfully' )
1541+
1542+
1543+ # vector won't be implemented, use python equivalent
0 commit comments