comparison tests/DynChannel.ur @ 2064:3dd041b00087

Extend ScriptCheck to take RPCs into account
author Adam Chlipala <adam@chlipala.net>
date Sun, 24 Aug 2014 11:43:49 -0400
parents
children
comparison
equal deleted inserted replaced
2063:83bdb52962c9 2064:3dd041b00087
1 table channels : {Id : int, Channel:channel xbody}
2
3 fun dosend (s:string) : transaction unit =
4 c <- oneRow1 (SELECT * FROM channels);
5 debug ("Sending " ^ s ^ " through the channel...");
6 send c.Channel <xml>{[s]}</xml>
7
8 fun mkchannel {} : transaction xbody =
9 c <- channel;
10 s <- source <xml/>;
11 dml( DELETE FROM channels WHERE Id >= 0);
12 dml( INSERT INTO channels(Id, Channel) VALUES(0, {[c]}) );
13 return <xml>
14 <button value="Send" onclick={fn _ => rpc(dosend "blabla")}/>
15 <active code={spawn(x <- recv c; alert ("Got something from the channel"); set s x); return <xml/>}/>
16 <dyn signal={signal s}/>
17 </xml>
18
19 fun main {} : transaction page =
20 s <- source <xml/>;
21 return <xml>
22 <head/>
23 <body>
24 <button value="Register" onclick={fn _ =>
25 x <- rpc(mkchannel {}); set s x
26 }/>
27 <dyn signal={signal s}/>
28 </body>
29 </xml>