@@ -1543,4 +1543,93 @@ async def test_pocket(api):
15431543 await api .print ('Test finished successfully' )
15441544
15451545
1546+ async def test_multishell (api ):
1547+ from computercraft .subapis .multishell import MultishellAPI
1548+ tbl = await get_object_table (api , 'multishell' )
1549+ assert get_class_table (MultishellAPI ) == tbl
1550+
1551+ await step (api , 'Close all additional shells' )
1552+
1553+ assert await api .multishell .getCount () == 1
1554+ assert await api .multishell .getCurrent () == 1
1555+ assert await api .multishell .getFocus () == 1
1556+ assert isinstance (await api .multishell .getTitle (1 ), str )
1557+
1558+ title = f'new title { random .randint (1 , 1000000 )} '
1559+ assert await api .multishell .setTitle (1 , title ) is None
1560+ assert await api .multishell .getTitle (1 ) == title
1561+
1562+ assert await api .multishell .setFocus (1 ) is True
1563+ assert await api .multishell .setFocus (0 ) is False
1564+ assert await api .multishell .setFocus (2 ) is False
1565+
1566+ assert await api .multishell .getTitle (2 ) is None
1567+
1568+ assert await api .multishell .launch ({}, 'rom/programs/fun/hello.lua' ) == 2
1569+ assert isinstance (await api .multishell .getTitle (2 ), str )
1570+
1571+ await api .print ('Test finished successfully' )
1572+
1573+
1574+ async def test_shell (api ):
1575+ from computercraft .subapis .shell import ShellAPI
1576+ tbl = await get_object_table (api , 'shell' )
1577+
1578+ del tbl ['function' ]['setCompletionFunction' ]
1579+ del tbl ['function' ]['getCompletionInfo' ]
1580+ assert get_class_table (ShellAPI ) == tbl
1581+
1582+ assert await api .shell .complete ('ls ro' ) == ['m/' , 'm' ]
1583+ assert await api .shell .completeProgram ('lu' ) == ['a' ]
1584+
1585+ ps = await api .shell .programs ()
1586+ assert 'shutdown' in ps
1587+
1588+ als = await api .shell .aliases ()
1589+ assert 'ls' in als
1590+ assert als ['ls' ] == 'list'
1591+ assert 'xls' not in als
1592+ assert await api .shell .setAlias ('xls' , 'list' ) is None
1593+ als = await api .shell .aliases ()
1594+ assert 'xls' in als
1595+ assert als ['xls' ] == 'list'
1596+ assert await api .shell .clearAlias ('xls' ) is None
1597+ als = await api .shell .aliases ()
1598+ assert 'xls' not in als
1599+
1600+ assert await api .shell .getRunningProgram () == 'py'
1601+
1602+ assert await api .shell .resolveProgram ('doesnotexist' ) is None
1603+ assert await api .shell .resolveProgram ('hello' ) == 'rom/programs/fun/hello.lua'
1604+
1605+ assert await api .shell .dir () == ''
1606+ assert await api .shell .resolve ('doesnotexist' ) == 'doesnotexist'
1607+ assert await api .shell .resolve ('startup.lua' ) == 'startup.lua'
1608+ assert await api .shell .setDir ('rom' ) is None
1609+ assert await api .shell .dir () == 'rom'
1610+ assert await api .shell .resolve ('startup.lua' ) == 'rom/startup.lua'
1611+ assert await api .shell .setDir ('' ) is None
1612+
1613+ assert isinstance (await api .shell .path (), str )
1614+ assert await api .shell .setPath (await api .shell .path ()) is None
1615+
1616+ assert await api .shell .execute ('hello' ) is True
1617+ assert await api .shell .run ('hello' ) is True
1618+ assert await api .shell .execute ('doesnotexist' ) is False
1619+ assert await api .shell .run ('doesnotexist' ) is False
1620+
1621+ tab = await api .shell .openTab ('hello' )
1622+ assert isinstance (tab , int )
1623+
1624+ await step (api , f'Program has been launched in tab { tab } ' )
1625+
1626+ assert await api .shell .switchTab (tab ) is None
1627+
1628+ await step (api , 'Computer will shutdown after test due to shell.exit' )
1629+
1630+ assert await api .shell .exit () is None
1631+
1632+ await api .print ('Test finished successfully' )
1633+
1634+
15461635# vector won't be implemented, use python equivalent
0 commit comments