bork
[clean-tests.git] / test.icl
1 module test
2
3 import Debug.Trace
4 import iTasks
5
6 import iTasks.Extensions.DateTime
7 import iTasks.UI.Layout.Minimal
8
9 Start w = doTasksWithOptions opt w2 w
10 where
11 t :: Task DateTime
12 t = waitForTimer 7
13 t2 :: Task Int
14 t2 = enterInformation () [] >>= viewInformation () []
15 t3 :: Task String
16 t3 = withShared 3 \sh->
17 withTemporaryDirectory (viewInformation () [])
18 >>= viewInformation () []
19 t4 = updateInformation () [] 42
20
21 t5 = sequence [return i\\i<-[0..1000]] >>= viewInformation () []
22 t6 = waitForTimer 10
23
24 t7 :: Int -> Task Int
25 t7 i = viewInformation () [] i >>= \x->t7 (x + 1)
26
27 t8 = viewInformation () [] 1
28 >>= \_->(viewInformation () [] 2
29 >>= \_->viewInformation () [] 3
30 >>= \_->viewInformation () [] 4)
31
32 p = parallel [(Embedded, \_->waitForTimer 5)] []
33 p1 = waitForTimer 5 -||- waitForTimer 10
34 p2 = withShared 3 \sh->watch sh
35
36 w1 = withShared 0 \sds -> (watch sds @? trace_stdout) -&&- updateInformation () [] 0 -&&- updateSharedInformation () [] sds
37
38 w2 = withShared 0 \sds ->
39 updateSharedInformation () [] sds
40 -&&- (whileUnchanged sds (viewInformation () []) @? trace_stdout)
41
42 w3 = forever (viewInformation () [] 32) @? trace_stdout
43
44 opt args eo = Ok eo
45 // opt args eo = Ok {eo & autoLayout=False}
46
47 /*
48 //import StdEnv
49 //import Data.Error
50 //import Data.Maybe
51 //import Network.IP
52 //import System.Socket
53 //import System.Socket.Ipv4
54 ////import System.Select
55 //
56 from Data.Map import singleton
57 import Data.Map.GenJSON
58 //import Data.Func
59 import iTasks
60
61 import iTasks.Extensions.Files
62
63 //Start w = doTasks (onStartup (copyFile "/home/mrl/test.txt" "/home/mrl/test2.txt")) w
64 //Start w = doTasks (onStartup (workAs SystemUser (return 42))) w
65 Start w = doTasks t w
66
67 t = viewInformation () [] ()
68 >>* [OnAction ActionOk (always (return ()))
69 ,OnAction ActionQuit (always (return ()))
70 ]
71
72 //Start w = doTasks t w
73 //
74 //t :: Task [(Int, TaskValue Int)]
75 //t = parallel
76 // [(Embedded, \stl->
77 // appendTask Embedded (\_->viewInformation "Int" [] 42) stl
78 // >>! \i->set (singleton "focus" "true") (sdsFocus i (taskListEntryMeta stl))
79 // >>~ \_->viewSharedInformation "Parallel task list" []
80 // (sdsFocus {onlyIndex=Nothing,onlyTaskId=Nothing,onlySelf=False,includeValue=True,includeProgress=True,includeAttributes=True} stl)
81 // @! 42
82 // )] []
83
84
85 //import StdGeneric
86 //
87 //generic g a :: a
88 //
89 //g{|*|} = 42
90
91 //Start :: *World -> (MaybeOSError String, *World)
92 //Start w
93 // = case socket SocketStream w of
94 // (Error e, w) = (Error e, w)
95 // (Ok sockfd, w)
96 // #! (merr, sockfd) = connect {ipv4_socket_port=8124,ipv4_socket_addr=Just (fromString "127.0.0.1")} sockfd
97 // | isError merr = (liftError merr, w)
98 // #! (merr, sockfd) = recv 128 [] sockfd
99 // | isError merr = (merr, w)
100 // # (Ok msg) = merr
101 // # (merr, w) = close sockfd w
102 // | isError merr = (liftError merr, w)
103 // = (Ok msg, w)
104 */