# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ Miranda methods on E-implemented objects ? def thing { > to getX() :void { return 52 } > } # value: ? thing.__getAllegedType() # value: Thing ? thing.__order("__getAllegedType", []) # value: [Thing, ] Miranda methods on native (in E-on-CL, DEF-VTABLE-based) objects ? def specimen := 44.0 # value: 44.0 ? specimen.__getAllegedType() # value: float64 ? specimen.__order("__getAllegedType", []) # value: [float64, 44.0] Miranda methods on E-on-CL E-LAMBDA-based objects ? __loop.__getAllegedType() # value: Loop ? __loop.__order("__getAllegedType", []) # value: [Loop, <__loop>] Er. After writing the above, I combined all of the miranda-method implementations. So, having tested dispatching to miranda methods, the following tests will not necessarily exercise all cases of miranda dispatch. ? [__loop.__optUncall()] # value: [null] ? [thing.__optUncall()] # value: [null] ? [specimen.__optUncall()] # value: [null] xxx should miranda __reactToLostClient coerce to exception? ? [specimen.__reactToLostClient("bang")] # value: [null] XXX __reactToLostClient on breakable refs (which we don't have yet) ' whenMoreResolved ? var gotWMR := "foo" # value: "foo" ? [specimen.__whenMoreResolved(def wmrReactor(arg) :void {gotWMR := arg}), gotWMR] # value: [null, "foo"] XXX we should waitAtTop on something resolved by the reactor here, to make the updoc script reliable ? gotWMR # value: 44.0 Checking that the WMR reactor is invoked sendOnly. ? specimen <- __whenMoreResolved( > (def handler match msg { print(msg) }, > Ref.promise()[0], false)); null ? # stdout: ["handleSendOnly", ["run", [44.0]]] whenBroken ? [specimen.__whenBroken(fn{print("oops")})] # value: [null] __whenBroken on breakable refs is not a miranda method. getPropertySlot tests may be found in properties.updoc optSealedDispatch Java-E would reject this because "bang" is not an elib.sealing.Brand. I decided this is unnecessarily restrictive, since one may wish to create new kinds of brands. ? [specimen.__optSealedDispatch("bang")] # value: [null] conformTo ? specimen.__conformTo(any) # value: 44.0 ? specimen.__conformTo(void) # value: 44.0 __respondsTo, of course, is dependent on the dispatch implementation, so it shall be tested for many object types again. ? def testRespond(specimen, vas) :any { > var r := [] > for [verb, arity] in vas { > def normal := specimen.__respondsTo(verb, arity) > def reffed := specimen.__respondsTo({(def x).resolve(verb); x}, > {(def x).resolve(arity); x}) > require(normal == reffed, fn{ `$specimen didn't respond the same to a Ref-ified $verb/$arity: $reffed instead of $normal` }) > r with= normal > } > return r > } # value: ? testRespond(thing, [["frog", 1], ["getX", 0], ["getX/1", 1]]) # value: [false, true, false] ? testRespond(specimen, [["add", 1], ["toad", 2]]) # value: [true, false] ? testRespond(__loop, [["newt", 3], ["run", 1]]) # value: [false, true] ? testRespond(thing, def respondses := [["__respondsTo", 1], ["__respondsTo", 2], ["__respondsTo", 3]]) # value: [false, true, false] ? testRespond(specimen, respondses) # value: [false, true, false] ? testRespond(__loop, respondses) # value: [false, true, false] XXX e-impls with matchers (or eg, stdout.print) __respondsTo should be passed to a matcher ? {def a extends (def b { to c(_) :any {} }) {}}.__respondsTo("c", 1) # value: true ? def nonmatches { match ==null { "oops" } }.__respondsTo("foo", 0) # value: false XXX __getAllegedType Detailed testing of __getAllegedType/0 is in help.updoc.