tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

IOBoundaryTests.hs (1279B)


      1 -- The old path-grant sandbox is retired, not silently relaxed. Current resource
      2 -- ownership/lease/cancellation controls live in the IO suites; OS permissions
      3 -- and real TCP/filesystem protocols also have independent CLI acceptance.
      4 module IOBoundaryTests (ioBoundaryTests) where
      5 
      6 import IODriver
      7 import Runtime
      8 import Control.Monad (forM_)
      9 import qualified Data.ByteString as BS
     10 import System.Directory (listDirectory)
     11 import System.IO.Temp (withSystemTempDirectory)
     12 import Test.Tasty
     13 import Test.Tasty.HUnit
     14 
     15 ioBoundaryTests :: TestTree
     16 ioBoundaryTests = testGroup "Retired protocol effect boundary"
     17   [ testCase "v1 writes, removal and publication cannot modify filesystem" $
     18       withSystemTempDirectory "retired-io" $ \directory -> do
     19         let path = directory ++ "/existing"
     20         BS.writeFile path (BS.pack [0,255,10])
     21         forM_ [21,25,26,33,36,52,60,61,62,63] $ \tag -> do
     22           let payload = Fork (ofString path) (ofString "replacement")
     23               action = Fork (ofNumber tag) payload
     24               envelope = Fork (ofString "tricuIO") (Fork (ofNumber 1) action)
     25           runIO envelope >>= (@?= Left "Unsupported tricuIO version")
     26           BS.readFile path >>= (@?= BS.pack [0,255,10])
     27           listDirectory directory >>= (@?= ["existing"])
     28   ]