convert many more test cases
[fleet.git] / ships / Fifo.ship
1 ship: Fifo
2
3 == Ports ===========================================================
4 data  in:   in
5 data  out:  out
6
7 == Constants ========================================================
8 == TeX ==============================================================
9 == Fleeterpreter ====================================================
10     private Queue<Long> fifo = new LinkedList<Long>();
11     public void service() {
12         if (box_in.dataReadyForShip()) {
13             fifo.add(box_in.removeDataForShip());
14         }
15         if (box_out.readyForDataFromShip() && fifo.size() > 0) {
16             box_out.addDataFromShip(fifo.remove());
17         }
18     }
19
20 == FleetSim ==============================================================
21
22 == Test =================================================================
23 // expected output
24 #expect 9
25
26 // ships required in order to run this code
27 #ship debug        : Debug
28 #ship fifo         : Fifo
29
30 debug.in:   [*] take, deliver;
31 fifo.in:
32   literal 9;
33   deliver;
34   [100] take, deliver;
35 fifo.out:
36   [99] take, sendto fifo.in;
37   [1]  take, sendto debug.in;
38
39
40
41 == Contributors =========================================================
42 Adam Megacz <megacz@cs.berkeley.edu>