# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ XXX invent non-Java FQNs ? def Exception := # value: Throwable ? def Throwable := # value: Throwable ? Exception == Throwable # value: true --- Simple string exception --- ? def makeStringException :DeepFrozen := # value: ? def StringException := makeStringException.asType() # value: StringException ? def stringEx := "a" :Throwable # value: problem: a ? stringEx :Throwable # value: problem: a ? stringEx :StringException # value: problem: a ? 1 :StringException # problem: the int 1 doesn't coerce to a StringException ? Ref.isPassByCopy(stringEx) # value: true ? stringEx.__optUncall() # value: [, "run", ["a"]] ? stringEx.__optUncall()[0] == makeStringException # value: true ? stringEx == E.call(E, "call", stringEx.__optUncall()) # value: true XXX the following are really testing ; should be moved elsewhere ? def muc := .optUncall(stringEx.__optUncall()[0]) # value: [, "get", ["org.cubik.cle.prim.makeStringException"]] XXX should return .fail. FQN ? == stringEx.__optUncall()[0] # value: true ? == stringEx.__optUncall()[0] # value: true ? muc[0] == # value: true format-string-proofing tests ? [def formatTest := "~%" :Throwable, formatTest.__optUncall()] # value: [problem: ~%, [, "run", ["~%"]]] ? "~~" :Throwable # value: problem: ~~ ? "~a~" :Throwable # value: problem: ~a~ --- CoercionFailure --- ? def CoercionFailure := # value: CoercionFailure ? def makeCoercionFailure := # value: ? Ref.optProblem(Ref.broken("X")) :CoercionFailure # problem: the StringException problem: X doesn't coerce to a CoercionFailure ? def typeError :CoercionFailure := escape ex { String.coerce(0, ex) } # value: problem: the int 0 doesn't coerce to a String ? typeError.getSpecimen() # value: 0 ? typeError.getGuard() # value: String ? Ref.isPassByCopy(typeError) # value: true ? typeError.__optUncall() # value: [, "run", [0, String]] ? typeError.__optUncall()[0] == makeCoercionFailure # value: true ? typeError == E.call(E, "call", typeError.__optUncall()) # value: true check for near-assumptions ? makeCoercionFailure({def p; p}, String) # value: problem: doesn't coerce to a String XXX correct? XXX test