001 // Copyright 2007-2009 Waterken Inc. under the terms of the MIT X license 002 // found at http://www.opensource.org/licenses/mit-license.html 003 package org.waterken.all; 004 005 import static org.ref_send.test.Logic.join; 006 007 import org.ref_send.list.List; 008 import org.ref_send.promise.Eventual; 009 import org.ref_send.promise.Promise; 010 import org.ref_send.promise.Vat; 011 import org.waterken.bang.Bang; 012 import org.waterken.bang.Beat; 013 import org.waterken.bang.Drum; 014 import org.waterken.bounce.Bounce; 015 import org.waterken.bounce.Pitch; 016 import org.waterken.bounce.Wall; 017 import org.waterken.delayed.Forwarder; 018 import org.waterken.delayed.ForwarderMaker; 019 import org.waterken.delayed.Relay; 020 import org.waterken.eq.SoundCheck; 021 import org.waterken.pipelined.Pipelined; 022 import org.waterken.pipelined.PlugNPlay; 023 import org.waterken.pipelined.PlugNPlayMaker; 024 import org.waterken.serial.PopPushN; 025 026 /** 027 * Runs all tests. 028 */ 029 public final class 030 All { 031 private All() { /* no instance interface */ } 032 033 /** 034 * Constructs an instance. 035 * @param _ eventual operator 036 */ 037 static public Promise<?> 038 make(final Eventual _) throws Exception { 039 _.log.comment("testing EQ operations on promises"); 040 final Promise<?> a = SoundCheck.make(_); 041 042 _.log.comment("testing argument passing"); 043 final Vat<Wall> wall = _.spawn("wall", Bounce.class); 044 final Promise<?> b = Pitch.make(_, wall.top); 045 046 _.log.comment("testing message pipelining"); 047 final Vat<Drum> drum = _.spawn("drum", Bang.class); 048 final Promise<?> c = Beat.make(_, drum.top); 049 050 _.log.comment("testing promise resolution"); 051 final Promise<?> d = PopPushN.make(_, 4); 052 053 _.log.comment("testing delayed resolution"); 054 final Vat<Forwarder> forwarder = _.spawn("delay", ForwarderMaker.class); 055 final Promise<?> e = Relay.make(_, forwarder.top); 056 057 _.log.comment("testing promise pipelining"); 058 final Vat<PlugNPlay> player = _.spawn("pipeline", PlugNPlayMaker.class); 059 final Promise<?> f = Pipelined.make(player.top); 060 061 return join(_, a, b, c, d, e, f); 062 } 063 064 // Command line interface 065 066 /** 067 * Executes the test. 068 * @param args ignored 069 * @throws Exception test failed 070 */ 071 static public void 072 main(final String[] args) throws Exception { 073 final List<Promise<?>> work = List.list(); 074 final Promise<?> result = make(new Eventual(work.appender())); 075 while (!work.isEmpty()) { work.pop().call(); } 076 result.call(); 077 } 078 }