#!/usr/bin/env rune # Copyright 2002 Combex, Inc. under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ # This file was copied from svn://svn.synchrona.org/erights/e/trunk/src/jsrc/net/captp/tables/AnswersTable.updoc, revision 443. This file is for testing the AnswersTable. First we obtain the maker: ? pragma.syntax("0.8") ? def AnswersTableMaker := # value: Then we make an instance: ? def at1 := AnswersTableMaker() # value: ? at1.size() # value: 0 ? def i1 := at1."bind"("foo") # value: 1 ? at1 # value: ? at1.size() # value: 1 ? def i2 := at1."bind"("bar") # value: 2 ? at1 # value: ? at1.free(i1) ? at1 # value: ? at1.get(i2) # value: "bar" ? at1[i2] # value: "bar" ? at1[i1] # problem: 1 not alloced in AnswersTable__1 ? at1.mustBeFree(i1) ? at1.mustBeFree(i2) # problem: 2 not free in AnswersTable__1 ? at1.mustBeAlloced(i1) # problem: 1 not alloced in AnswersTable__1 ? at1.mustBeAlloced(i2) ? at1 # value: ? at1.incr(i2) ? at1.incr(i2) ? at1.incr(i1) # problem: 1 not alloced in AnswersTable__1 ? at1 # value: ? at1.decr(i2, 1) # value: false ? at1.decr(i2, 1) # value: false ? at1.decr(i2, 1) # value: true ? at1 # value: ? at1."bind"("zippy") # value: 2 ? def dms { > to __reactToLostClient(problem) :void { > println(`client gone because $problem`) > } > to __printOn(out :TextWriter) :void { > out.print("Dead Man Switch") > } > } # value: Dead Man Switch ? at1."bind"(dms) # value: 1 ? at1 # value: ? def problem := "fooey" :() # value: problem: fooey ? at1.smash(problem) # stdout: client gone because problem: fooey # ? at1[i2] # problem: 2 not alloced in AnswersTable__1 ? at1[i1] # problem: 1 not alloced in AnswersTable__1 ? at1."bind"("glorp") # problem: cannot bind in ? (for i in 1..3 { > println(`i: $i`) > } > 44) # stdout: i: 1 # i: 2 # i: 3 # # value: 44 ?