# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? [1, 2] + [3, 4] # value: [1, 2, 3, 4] ? [1, 2, 2].asMap() # value: [0 => 1, 1 => 2, 2 => 2] Bad indexes ? def indexTest := ["a", "b", "c"]; null ? indexTest[-1] # problem: the int -1 doesn't coerce to an int[0] XXX visible CL-style range type ? indexTest[3] # problem: list index 3 is out of range for size 3 list ["a", "b", "c"] asKeys/1 ? [1, 2, 2].asKeys() # value: [1 => null, 2 => null] ? [].asKeys() # value: [].asMap() ? [null, 4, 1, 2, 3, 4, 5, 6, 7].asKeys() # value: [null => null, 4 => null, 1 => null, 2 => null, 3 => null, 5 => null, 6 => null, 7 => null] ? [1, 2, 2].asSet() # value: [1, 2].asSet() ? ["a", 'b', 3].last() # value: 3 ? ["a", ['b'], 3].__optUncall() # value: [, "run", ["a", ['b'], 3]] coercion ? ['a', 'b'][def _ { to __conformTo(_) :any { return 1 }}] # value: 'b' startOf/1-2 ? [1, 1, 2, 1, 2].startOf([1, 2]) # value: 1 ? [1, 1, 2, 1, 2].startOf([2, 2]) # value: -1 ? [1, 1, 2, 1, 2].startOf([1, 2], 2) # value: 3 ? [1, 1, 2, 1, 2].startOf([1, 2], 4) # value: -1 sort ? [3, 2, 1].sort() # value: [1, 2, 3] ? [1, 2, 3].sort(def reverseCompare(a, b) :any { return -(a.op__cmp(b)) }) # value: [3, 2, 1] XXX consider how to test all the same methods on Strings (or, for String-specific quirks, coercions, etc.) last ? ["a", "b", "c"].last() # value: "c" ? [].last() # problem: [] has no last element makeList ? def makeConstList :DeepFrozen := # value: ? __makeList == makeConstList # value: true ? makeConstList.unrecognized() # problem: no such method: org.erights.e.elib.tables.makeConstList#unrecognized/0 ? def PList := makeConstList.asType() # value: ConstList ? PList == List # value: false XXX this should be true -- make List.emaker into a sugar ? for x :PList in [[1,2], "ab", null, def x {}, {def p;p}] { println(x) } # stdout: [1, 2] # ab #