DefaultBehavior is a mixin that provides most of the methods shared by most instances in the system.

Mimics
Inactive cells
Active cells
Specs
DefaultBehavior !
  • - should return the result of calling not on the object [ show source ]
    x = Origin mimic 
    x not = method(53) 
    !(x should) ==(53) 
    x = Origin mimic 
    x not = method(33) 
    !(x should) ==(33) 
    
    
DefaultBehavior %=
  • - should call % and then assign the result of this call to the same name [ show source ]
    x = 12 
    %=(x, 5) 
    x should ==(2) 
    x = 13 
    %=(x, 4) 
    x should ==(1) 
    
    
  • - should work with a place [ show source ]
    x = [](42) 
    x %=([](0), 4) 
    x [](0) should ==(2) 
    
    
DefaultBehavior &&
  • - should evaluate it's argument [ show source ]
    x = 41 
    13 &&(x = 42) 
    x should ==(42) 
    
    
  • - should return the result of the argument [ show source ]
    5353 &&(42) should ==(42) 
    
    
  • - should be available in infix [ show source ]
    ("flurg" &&(43)) should ==(43) 
    
    
DefaultBehavior &&=
  • - should not assign a cell if it doesn't exist [ show source ]
    &&=(xblurg, 42) 
    cell?(:xblurg) should be false 
    
    
  • - should not assign a cell if it is nil [ show source ]
    x = nil 
    &&=(x, 42) 
    x should be nil 
    
    
  • - should not assign a cell if it is false [ show source ]
    x = false 
    &&=(x, 42) 
    x should be false 
    
    
  • - should assign a cell that exist [ show source ]
    x = 43 
    &&=(x, 42) 
    x should ==(42) 
    
    
  • - should work with a place [ show source ]
    x = [](1, 3) 
    x &&=([](1), 42) 
    x should ==([](1, 42)) 
    x = [](2, 3) 
    x &&=([](2), 42) 
    x should ==([](2, 3)) 
    x = [](3, nil) 
    x &&=([](1), 42) 
    x should ==([](3, nil)) 
    x = [](4, false) 
    x &&=([](1), 42) 
    x should ==([](4, false)) 
    
    
DefaultBehavior &=
  • - should call & and then assign the result of this call to the same name [ show source ]
    x = 65535 
    &=(x, 1) 
    x should ==(1) 
    x = 8 
    &=(x, 8) 
    x should ==(8) 
    
    
  • - should work with a place [ show source ]
    x = [](65535) 
    x &=([](0), 1) 
    x [](0) should ==(1) 
    
    
DefaultBehavior '
  • - should return the things inside unevaluated [ show source ]
    '(+(200)) name should ==(:("+")) 
    '(abc foo bar quux lux) name should ==(:abc) 
    
    
DefaultBehavior ''
  • - should work exactly like ' for anything not containing a ` or ' [ show source ]
    ''(+(200)) name should ==(:("+")) 
    ''(abc foo bar quux lux) name should ==(:abc) 
    ''(foo(bar +(quux(123)))) code should ==("foo(bar +(quux(123)))") 
    
    
  • - should splice a message that is the result of a ` form [ show source ]
    ''(mux `('(foo))) code should ==("mux foo") 
    ''(mux(`('(foo)))) code should ==("mux(foo)") 
    xx = '(foo bar(if(true))) 
    ''(max `(xx)) code should ==("max foo bar(if(true))") 
    mux = '(message) 
    out = ''(mux `(mux)) 
    mux <<('(foo)) 
    out code should ==("mux message(foo)") 
    
    
  • - should splice a message that is a deep copy of a ' form [ show source ]
    mux = '(message) 
    ''(mux '(mux)) code should ==("mux message") 
    out = ''(mux '(mux)) 
    mux <<('(foo)) 
    out code should ==("mux message") 
    
    
  • - should resplize an argument list to a spliced message without arguments [ show source ]
    ''(mux `('(one)) (123, 456)) code should ==("mux one(123, 456)") 
    
    
  • - should wrap a cached result if the result from a ` form is not a message [ show source ]
    ''(mux(`(123))) code should ==("mux(123)") 
    ''(mux(`(123))) code should ==("mux(123)") 
    flarg = 123 
    ''(mux(`(flarg))) code should ==("mux(123)") 
    ''(mux(`(flarg))) code should ==("mux(123)") 
    
    
  • - should should insert a literal ` if a `` message is encountered [ show source ]
    ''(mux ``(abc)) code should ==("mux `(abc)") 
    
    
  • - should should insert a literal ' if a '' message is encountered [ show source ]
    ''(mux ''(abc)) code should ==("mux '(abc)") 
    
    
DefaultBehavior **=
  • - should call ** and then assign the result of this call to the same name [ show source ]
    x = 2 
    **=(x, 3) 
    x should ==(8) 
    x = 2 
    **=(x, 40) 
    x should ==(1099511627776) 
    
    
  • - should work with a place [ show source ]
    x = [](3) 
    x **=([](0), 2) 
    x [](0) should ==(9) 
    
    
DefaultBehavior *=
  • - should call * and then assign the result of this call to the same name [ show source ]
    x = 12 
    *=(x, 2) 
    x should ==(24) 
    x = 150 
    *=(x, -(2)) 
    x should ==(-(300)) 
    
    
  • - should work with a place [ show source ]
    x = [](42) 
    x *=([](0), 2) 
    x [](0) should ==(84) 
    
    
DefaultBehavior +=
  • - should call + and then assign the result of this call to the same name [ show source ]
    x = 1 
    +=(x, 2) 
    x should ==(3) 
    x = 42 
    +=(x, -(1)) 
    x should ==(41) 
    
    
  • - should work with a place [ show source ]
    x = [](1) 
    x +=([](0), 2) 
    x [](0) should ==(3) 
    
    
DefaultBehavior -=
  • - should call - and then assign the result of this call to the same name [ show source ]
    x = 2 
    -=(x, 1) 
    x should ==(1) 
    x = 42 
    -=(x, -(1)) 
    x should ==(43) 
    
    
  • - should work with a place [ show source ]
    x = [](42) 
    x -=([](0), 2) 
    x [](0) should ==(40) 
    
    
DefaultBehavior ..
  • - should create a range from 0 to 0 [ show source ]
    (0 ..(0)) should have kind("Range") 
    (0 ..(0)) from should ==(0) 
    (0 ..(0)) to should ==(0) 
    
    
  • - should create a range from 0 to 1 [ show source ]
    (0 ..(1)) should have kind("Range") 
    (0 ..(1)) from should ==(0) 
    (0 ..(1)) to should ==(1) 
    
    
  • - should create a range from 0 to -1 [ show source ]
    (0 ..(-(1))) should have kind("Range") 
    (0 ..(-(1))) from should ==(0) 
    (0 ..(-(1))) to should ==(-(1)) 
    
    
  • - should create a range from other numbers [ show source ]
    (23 ..(-(342))) should have kind("Range") 
    (23 ..(-(342))) from should ==(23) 
    (23 ..(-(342))) to should ==(-(342)) 
    
    
  • - should create an inclusive range [ show source ]
    (0 ..(0)) inclusive? should true 
    
    
DefaultBehavior ...
  • - should create a range from 0 to 0 [ show source ]
    (0 ...(0)) should have kind("Range") 
    (0 ...(0)) from should ==(0) 
    (0 ...(0)) to should ==(0) 
    
    
  • - should create a range from 0 to 1 [ show source ]
    (0 ...(1)) should have kind("Range") 
    (0 ...(1)) from should ==(0) 
    (0 ...(1)) to should ==(1) 
    
    
  • - should create a range from 0 to -1 [ show source ]
    (0 ...(-(1))) should have kind("Range") 
    (0 ...(-(1))) from should ==(0) 
    (0 ...(-(1))) to should ==(-(1)) 
    
    
  • - should create a range from other numbers [ show source ]
    (23 ...(-(342))) should have kind("Range") 
    (23 ...(-(342))) from should ==(23) 
    (23 ...(-(342))) to should ==(-(342)) 
    
    
  • - should create an inclusive range [ show source ]
    (0 ...(0)) inclusive? should be false 
    
    
DefaultBehavior /=
  • - should call / and then assign the result of this call to the same name [ show source ]
    x = 12 
    /=(x, 2) 
    x should ==(6) 
    x = 150 
    /=(x, -(2)) 
    x should ==(-(75)) 
    
    
  • - should work with a place [ show source ]
    x = [](42) 
    x /=([](0), 2) 
    x [](0) should ==(21) 
    
    
DefaultBehavior <<=
  • - should call << and then assign the result of this call to the same name [ show source ]
    x = 7 
    <<=(x, 2) 
    x should ==(28) 
    x = 9 
    <<=(x, 4) 
    x should ==(144) 
    
    
  • - should work with a place [ show source ]
    x = [](9) 
    x <<=([](0), 4) 
    x [](0) should ==(144) 
    
    
DefaultBehavior =>
  • - should return a new pair for simple objects [ show source ]
    (23 =>(15)) first should ==(23) 
    (23 =>(15)) second should ==(15) 
    ("str" =>("foo")) first should ==("str") 
    ("str" =>("foo")) second should ==("foo")
    
  • - should return a new pair for more complicated expressions [ show source ]
    (23 +(15) -(2) =>(3332323 +(2))) first should ==(36) 
    (23 +(15) -(2) =>(3332323 +(2))) second should ==(3332325)
    
DefaultBehavior >>=
  • - should call >> and then assign the result of this call to the same name [ show source ]
    x = 7 
    >>=(x, 1) 
    x should ==(3) 
    x = 4095 
    >>=(x, 3) 
    x should ==(511) 
    
    
  • - should work with a place [ show source ]
    x = [](7) 
    x >>=([](0), 1) 
    x [](0) should ==(3) 
    
    
DefaultBehavior ?&
  • - should evaluate it's argument [ show source ]
    x = 41 
    13 ?&(x = 42) 
    x should ==(42) 
    
    
  • - should return the result of the argument [ show source ]
    5353 ?&(42) should ==(42) 
    
    
  • - should be available in infix [ show source ]
    ("flurg" ?&(43)) should ==(43) 
    
    
DefaultBehavior ?|
  • - should not evaluate it's argument [ show source ]
    x = 41 
    123 ?|(x = 42) 
    x should ==(41) 
    
    
  • - should return the receiver [ show source ]
    "murg" ?|(42) should ==("murg") 
    
    
  • - should be available in infix [ show source ]
    (444 ?|(43)) should ==(444) 
    
    
DefaultBehavior Aspects
  • - should be possible to combine the different types of advice [ show source ]
    Ground accesses = [] 
    x = Origin mimic do(
        foo = method(arg, 
            accesses <<([](:realMethod, arg)) 
            18 
            )) 
    x around(:foo) <<(fn(arg1, arg2, accesses <<([](:around1, arg1, arg2)) 
        aspectCall(arg2) *(2))) 
    x before(:foo) <<(method(+(args), accesses <<([](:before1, args)))) 
    x after(:foo) <<(method(+(args), accesses <<([](:after1, args, aspectResult)))) 
    x around(:foo) <<(method(+(args), accesses <<([](:around2, args)) 
        aspectCall(*(args map(*(2)))))) 
    x foo(1, 2) should ==(36) 
    accesses should ==([]([](:around2, [](1, 2)), [](:before1, [](2, 4)), [](:around1, 2, 4), [](:realMethod, 4), [](:after1, [](2, 4), 36))) 
    
    
DefaultBehavior Case
DefaultBehavior Conditions
DefaultBehavior Definitions
DefaultBehavior FlowControl
DefaultBehavior []
  • - should create a new empty list when given no arguments [ show source ]
    x = [] 
    x should have kind("List") 
    x should not be same(List) 
    x should mimic(List) 
    
    
  • - should create a new list with the evaluated arguments [ show source ]
    x = [](1, 2, "abc", 3 +(42)) 
    x length should ==(4) 
    x [](0) should ==(1) 
    x [](1) should ==(2) 
    x [](2) should ==("abc") 
    x [](3) should ==(45) 
    
    
DefaultBehavior ^=
  • - should call ^ and then assign the result of this call to the same name [ show source ]
    x = 3 
    ^=(x, 5) 
    x should ==(6) 
    x = -(2) 
    ^=(x, -(255)) 
    x should ==(255) 
    
    
  • - should work with a place [ show source ]
    x = [](3) 
    x ^=([](0), 5) 
    x [](0) should ==(6) 
    
    
DefaultBehavior `
  • - should return something with a name of cachedResult [ show source ]
    `(42) name should ==(:cachedResult) 
    
    
  • - should evaluate its argument [ show source ]
    `(Ground flurg = 444) 
    flurg should ==(444) 
    
    
  • - should return a message [ show source ]
    `(42) should have kind("Message") 
    
    
  • - should return something that when evaluated yields the value sent to the wrap method [ show source ]
    x = 55 
    m = `(x) 
    m evaluateOn(Ground, Ground) should be same(x) 
    
    
DefaultBehavior and
  • - should evaluate it's argument [ show source ]
    x = 41 
    13 and(x = 42) 
    x should ==(42) 
    
    
  • - should return the result of the argument [ show source ]
    5353 and(42) should ==(42) 
    
    
  • - should be available in infix [ show source ]
    ("flurg" and(43)) should ==(43) 
    
    
DefaultBehavior asText
  • - should call toString and return the text from that [ show source ]
    Origin mimic asText should match(#/^#<Origin:[0-9A-F]+>$/) 
    
    
DefaultBehavior become!
  • - should not be possible to have nil become something [ show source ]
    fn(nil become!(42)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be possible to have true become something [ show source ]
    fn(true become!(42)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be possible to have false become something [ show source ]
    fn(false become!(42)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should be possible to have a number become something else [ show source ]
    x = Origin mimic 
    
    y = -(324234534534145) 
    y become!(x) 
    y should have kind("Origin") 
    y asText should not ==("-324234534534145") 
    
    
  • - should be possible to have something become a number [ show source ]
    x = Origin mimic 
    y = 42 
    x become!(y) 
    x should have kind("Number") 
    x should ==(42) 
    
    
  • - should be possible to have a text become something else [ show source ]
    x = Origin mimic 
    y = "foobar" 
    y become!(x) 
    y should have kind("Origin") 
    y should not ==("foobar") 
    
    
  • - should be possible to have something become a text [ show source ]
    x = Origin mimic 
    y = "foobar" 
    x become!(y) 
    x should have kind("Text") 
    x should ==("foobar") 
    
    
  • - should return the receiver [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x become!(y) should be same(y) 
    
    
  • - should modify the reciever to have the same documentation [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x documentation = "foo" 
    y documentation = "quux" 
    x become!(y) 
    x documentation should ==("quux") 
    
    
  • - should give both objects the same uniqueHexId [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x uniqueHexId should not ==(y uniqueHexId) 
    y uniqueHexId should not ==(x uniqueHexId) 
    x become!(y) 
    x uniqueHexId should ==(y uniqueHexId) 
    y uniqueHexId should ==(x uniqueHexId) 
    
    
  • - should give objects that are the same [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x should not be same(y) 
    y should not be same(x) 
    x become!(y) 
    x should be same(y) 
    y should be same(x) 
    
    
  • - should give objects that mimic each other [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x become!(y) 
    x should be mimic(y) 
    y should be mimic(x) 
    
    
  • - should give objects that when modified will change each other [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x become!(y) 
    x z = 42 
    y z should ==(42) 
    y q = 35 
    x q should ==(35) 
    b = Origin mimic 
    x mimic!(b) 
    y should have mimic(b) 
    
    
DefaultBehavior break
  • - should have nil as value by default [ show source ]
    loop(break) should be nil 
    
    
  • - should take a return value [ show source ]
    loop(break(42)) should ==(42) 
    
    
DefaultBehavior derive
  • - should be able to derive from Origin [ show source ]
    result = Origin derive 
    result should have kind("Origin") 
    result should not be same(Origin) 
    
    
  • - should be able to derive from Ground [ show source ]
    result = Ground derive 
    result should have kind("Ground") 
    result should not be same(Ground) 
    
    
  • - should be able to derive from Text [ show source ]
    result = Text derive 
    result should have kind("Text") 
    result should not be same(Text) 
    
    
DefaultBehavior dict
  • - should create a new empty dict when given no arguments [ show source ]
    x = dict 
    x should be kind("Dict") 
    x should not be same(Dict) 
    x should mimic(Dict) 
    x = dict 
    x should be kind("Dict") 
    x should not be same(Dict) 
    x should mimic(Dict) 
    
    
  • - should create a new dict with the evaluated arguments [ show source ]
    result = dict(1 =>(2), "abc" =>(3 +(42)), :foo =>(123), :bar =>("x")) 
    result asList length should ==(4) 
    
    
  • - should create a new dict with keyword arguments [ show source ]
    result = dict(abc: 2, foo: 3 +(42), bar: 123, quux: "x") 
    result asList length should ==(4) 
    
    
  • - should take arguments that are not keyword or pairs and add nil as value for them [ show source ]
    dict(123, "foo", 13 +(2), :bar) should ==(dict(123 =>(nil), "foo" =>(nil), 15 =>(nil), :bar =>(nil))) 
    
    
  • - should take keyword arguments without a next pointer and add nil as value for them [ show source ]
    dict(foo:, bar:, quux:) should ==(dict(:foo =>(nil), :bar =>(nil), :quux =>(nil))) 
    
    
DefaultBehavior do
  • - should execute a piece of code inside an object [ show source ]
    r = Origin mimic 
    r do(
      s = 42 
      t = "str" 
      ) 
    cell?(:s) should be false 
    r s should ==(42) 
    r t should ==("str") 
    
    
DefaultBehavior documentation
  • - should be correct for internal:createText [ show source ]
    cell(:internal:createText) documentation should ==("expects one 'strange' argument. creates a new instance of Text with the given Java String backing it.") 
    
    
  • - should be correct for = [ show source ]
    cell(:("=")) documentation should ==("expects two or more arguments, the first arguments unevaluated, the last evaluated. assigns the result of evaluating the last argument in the context of the caller, and assigns this result to the name/s provided by the first arguments. the first arguments remains unevaluated. the result of the assignment is the value assigned to the name. if the last argument is a method-like object and it's name is not set, that name will be set to the name of the cell.") 
    
    
  • - should be correct for asText [ show source ]
    cell(:asText) documentation should ==("returns a textual representation of the object called on.") 
    
    
  • - should be correct for documentation [ show source ]
    cell(:documentation) documentation should ==("returns the documentation text of the object called on. anything can have a documentation text - this text will initially be nil.") 
    
    
  • - should be correct for cell [ show source ]
    cell(:cell) documentation should ==("expects one evaluated text or symbol argument and returns the cell that matches that name, without activating even if it's activatable.") 
    
    
  • - should be correct for method [ show source ]
    cell(:method) documentation should ==("expects any number of unevaluated arguments. if no arguments at all are given, will just return nil. creates a new method based on the arguments. this method will be evaluated using the context of the object it's called on, and thus the definition can not refer to the outside scope where the method is defined. (there are other ways of achieving this). all arguments except the last one is expected to be names of arguments that will be used in the method. there will possible be additions to the format of arguments later on - including named parameters and optional arguments. the actual code is the last argument given.") 
    
    
  • - should be correct for use [ show source ]
    cell(:use) documentation should ==("takes one or more evaluated string argument. will import the files corresponding to each of the strings named based on the Ioke loading behavior that can be found in the documentation for the loadBehavior cell on System.") 
    
    
DefaultBehavior false?
  • - should return true for nil [ show source ]
    nil false? should be true 
    
    
  • - should return true for false [ show source ]
    false false? should be true 
    
    
  • - should return false for true [ show source ]
    true false? should be false 
    
    
  • - should return false for a Number [ show source ]
    123 false? should be false 
    
    
  • - should return false for a Text [ show source ]
    "flurg" false? should be false 
    
    
DefaultBehavior fn
  • - should be possible to give it a documentation string [ show source ]
    fn("foo is bar", nil) documentation should ==("foo is bar") 
    
    
  • - should mimic LexicalBlock [ show source ]
    result = fn("hello" println) 
    result should have kind("LexicalBlock") 
    result should not ==(LexicalBlock) 
    
    
  • - should return nil when invoking 'call' on an empty block [ show source ]
    fn call should be nil 
    
    
  • - should be possible to execute it by invoking 'call' on it [ show source ]
    fn(1 +(1)) call should ==(2) 
    x = fn(42 +(4)) 
    x call 
    x call should ==(46) 
    
    
  • - should have access to variables in the scope it was defined, in simple do [ show source ]
    x = 26 
    fn(x) call should ==(26) 
    x = Origin mimic 
    x do(
      y = 42 
      z = fn(y +(1)) call) 
    x z should ==(43) 
    
    
  • - should have access to variables in the scope it was defined, in more complicated do [ show source ]
    x = Origin mimic 
    x do(
      y = 42 
      z = fn(y +(2))) 
    x z call should ==(44) 
    
    
  • - should have access to variables in the scope it was defined, in more nested blocks [ show source ]
    x = Origin mimic 
    x do(
      y = 42 
      z = fn(fn(y +(3)) call)) 
    x z call should ==(45) 
    
    
  • - should have access to variables in the scope it was defined, in method [ show source ]
    x = Origin mimic 
    x y = method(
        z = 42 
        fn(z +(5)) 
        ) 
    x y call should ==(47) 
    
    
  • - should have access to variables in the scope it was defined, in method, getting self [ show source ]
    x = Origin mimic 
    x y = method(
        fn(self) 
        ) 
    x y call should ==(x) 
    
    
  • - should take arguments [ show source ]
    fn(x, x) call(42) should ==(42) 
    fn(x, x +(2)) call(42) should ==(44) 
    fn(x, y, x +(y) +(2)) call(3, 7) should ==(12) 
    
    
  • - should complain when given the wrong number of arguments [ show source ]
    fn(fn call(42)) should signal(Condition Error Invocation TooManyArguments) 
    fn(fn(x, x) call) should signal(Condition Error Invocation TooFewArguments) 
    fn(fn(x, x) call(12, 42)) should signal(Condition Error Invocation TooManyArguments) 
    
    
  • - should be able to update variables in the scope it was defined [ show source ]
    x = Origin mimic 
    x do(
      y = 42 
      fn(y = 43) call 
      ) 
    x y should ==(43) 
    x = Origin mimic 
    x do(
      y = 44 
      zz = fn(y = 45) 
      ) 
    x zz call 
    x y should ==(45) 
    
    
  • - should create a new variable when assigning something that doesn't exist [ show source ]
    fn(blarg = 42 
      blarg) call should ==(42) 
    cell?(:blarg) should be false 
    
    
  • - should be possible to get the code for the block by calling 'code' on it [ show source ]
    fn code should ==("fn(nil)") 
    fn(nil) code should ==("fn(nil)") 
    fn(1) code should ==("fn(1)") 
    fn(1 +(1)) code should ==("fn(1 +(1))") 
    fn(x, x +(x)) code should ==("fn(x, x +(x))") 
    fn(x 12, x +(x)) code should ==("fn(x 12, x +(x))") 
    fn(x, x +(x) 
      x *(x)) code should ==("fn(x, x +(x) .\nx *(x))") 
    fn(x:, x +(x) 
      x *(x)) code should ==("fn(x: nil, x +(x) .\nx *(x))") 
    fn(x: 12, x +(x) 
      x *(x)) code should ==("fn(x: 12, x +(x) .\nx *(x))") 
    fn(x, +(rest), x +(x) 
      x *(x)) code should ==("fn(x, +rest, x +(x) .\nx *(x))") 
    fn(x, +:(rest), x +(x) 
      x *(x)) code should ==("fn(x, +:rest, x +(x) .\nx *(x))") 
    fnx code should ==("fnx(nil)") 
    fnx(nil) code should ==("fnx(nil)") 
    fnx(1) code should ==("fnx(1)") 
    fnx(1 +(1)) code should ==("fnx(1 +(1))") 
    fnx(x, x +(x)) code should ==("fnx(x, x +(x))") 
    fnx(x 12, x +(x)) code should ==("fnx(x 12, x +(x))") 
    fnx(x, x +(x) 
      x *(x)) code should ==("fnx(x, x +(x) .\nx *(x))") 
    fnx(x:, x +(x) 
      x *(x)) code should ==("fnx(x: nil, x +(x) .\nx *(x))") 
    fnx(x: 12, x +(x) 
      x *(x)) code should ==("fnx(x: 12, x +(x) .\nx *(x))") 
    fnx(x, +(rest), x +(x) 
      x *(x)) code should ==("fnx(x, +rest, x +(x) .\nx *(x))") 
    fnx(x, +:(rest), x +(x) 
      x *(x)) code should ==("fnx(x, +:rest, x +(x) .\nx *(x))") 
    
    
  • - should shadow reading of outer variables when getting arguments [ show source ]
    x = 32 
    fn(x, x) call(43) should ==(43) 
    x should ==(32) 
    
    
  • - should shadow writing of outer variables when getting arguments [ show source ]
    x = 32 
    fn(x, x = 13 
      x) call(123) should ==(13) 
    x should ==(32) 
    
    
DefaultBehavior fnx
  • - should be possible to give it a documentation string [ show source ]
    fnx("foo is bar", nil) documentation should ==("foo is bar") 
    
    
  • - should return something that is activatable for empty list [ show source ]
    fnx activatable should be true 
    
    
  • - should return something that is activatable for code [ show source ]
    fnx("hello") activatable should be true 
    
    
  • - should return something that is activatable for code with arguments [ show source ]
    fnx(x, y, x +(y)) activatable should be true 
    
    
DefaultBehavior freeze!
  • - should be possible to call several times without effect [ show source ]
    x = Origin mimic 
    x freeze! 
    x freeze! 
    
    
  • - should not be possible to modify a frozen object [ show source ]
    x = Origin mimic 
    x existing = 43 
    x freeze! 
    
    fn(x y = 42) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x existing = 42) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x mimic!(Origin mimic)) should signal(Condition Error ModifyOnFrozen) 
    fn(x prependMimic!(Origin mimic)) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x removeMimic!(Origin)) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x removeAllMimics!) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x documentation = "blarg") should signal(Condition Error ModifyOnFrozen) 
    
    fn(x become!(42)) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x removeCell!(:existing)) should signal(Condition Error ModifyOnFrozen) 
    
    fn(x undefineCell!(:existing)) should signal(Condition Error ModifyOnFrozen) 
    
    
  • - should be copied when becoming [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x freeze! 
    y become!(x) 
    y should be frozen 
    
    
DefaultBehavior frozen?
  • - should return false on something that isn't frozen [ show source ]
    x = Origin mimic 
    x should not be frozen 
    x freeze! 
    x should be frozen 
    
    
DefaultBehavior if
  • - should evaluate it's first element once [ show source ]
    x = 42 
    if(++(x)) 
    x should ==(43) 
    
    
  • - should return it's second argument if the first element evaluates to true [ show source ]
    if(true, 42, 43) should ==(42) 
    
    
  • - should return it's third argument if the first element evaluates to false [ show source ]
    if(false, 42, 43) should ==(43) 
    
    
  • - should return the result of evaluating the first argument if there are no more arguments [ show source ]
    if(44) should ==(44) 
    
    
  • - should return the result of evaluating the first argument if it is false and there are only two arguments [ show source ]
    if(false) should be false 
    if(nil) should be nil 
    
    
  • - should assign the test result to the variable it [ show source ]
    if(42, it) should ==(42) 
    if(nil, 42, it) should be nil 
    if(false, 42, it) should be false 
    if("str", 42, it) should ==(42) 
    
    
  • - should have a lexical context for the it variable [ show source ]
    if(42, fn(it)) call should ==(42) 
    
    
  • - should be possible to nest it variables lexically [ show source ]
    if(42, [](it, if(13, [](it, if(nil, 44, it), it)))) should ==([](42, [](13, nil, 13))) 
    
    
DefaultBehavior in?
  • - should call 'include?' on the argument with itself as argument [ show source ]
    x = Origin mimic 
    x include? = method(arg, [](arg, 42)) 
    y = Origin mimic 
    y in?(x) should ==([](y, 42)) 
    
    
  • - should return true if the object is in a list [ show source ]
    1 in?([](1, 2, 3)) should be true 
    
    
  • - should return false if the object is not in a list [ show source ]
    1 in?([](2, 3, 4)) should be false 
    
    
DefaultBehavior internal:compositeRegexp
  • - should combine several strings and expects the last entry to be a regular expression [ show source ]
    internal:compositeRegexp("abc", "foo", #/bar/) should ==(#/abcfoobar/) 
    
    
  • - should use the flags from the last regular expression [ show source ]
    internal:compositeRegexp("abc", #/ bar/mx) should ==(#/abc bar/mx) 
    
    
  • - should work in a literal syntax too [ show source ]
    internal:compositeRegexp(foo , "bar", , m) should ==(#/foo bar/m) 
    
    
DefaultBehavior internal:concatenateText
  • - should combine several strings [ show source ]
    "foobarflux" should ==("foobarflux") 
    x = "str" 
    "foo#{x}flux" should ==("foostrflux") 
    
    
  • - should combine strings with the text representation of other stuff [ show source ]
    "foo#{123}flux" should ==("foo123flux") 
    "#{[](1, 2, 3)}foo" should ==("[1, 2, 3]foo") 
    
    
DefaultBehavior internal:createText
  • - should be possible to invoke from Ioke with a regular String [ show source ]
    internal:createText("foo") should ==("foo") 
    
    
DefaultBehavior is?
  • - should return false if the object doesn't mimic the argument [ show source ]
    f = Origin mimic 
    Origin is?(f) should be false 
    f = Origin mimic 
    DefaultBehavior is?(f) should be false 
    f = Origin mimic 
    12 is?(f) should be false 
    f = Origin mimic 
    f is?(12) should be false 
    
    
  • - should return true if the object is the same as the argument [ show source ]
    f = Origin mimic 
    f is?(f) should be true 
    Origin is?(Origin) should be true 
    
    
  • - should return true if any of the mimics are the argument [ show source ]
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z is?(Origin) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z is?(x) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z is?(y) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z is?(z) should be true 
    f = Origin mimic 
    Origin mimic!(f) 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z is?(f) should be true 
    
    
  • - should handle a cycle of mimics correctly [ show source ]
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z is?(Number) should be false 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z is?(Origin) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z is?(Base) should be true 
    x = Origin mimic 
    x mimic!(x) 
    x is?(Origin) should be true 
    
    
DefaultBehavior kind?
  • - should return false if the kind doesn't match [ show source ]
    Text kind?("nil") should be false 
    Text kind?("Number") should be false 
    "" kind?("nil") should be false 
    "" kind?("Number") should be false 
    "" kind?("System") should be false 
    
    
  • - should return true if the current object has the kind [ show source ]
    Text kind?("Text") should be true 
    
    
  • - should return true if the main mimic has the kind [ show source ]
    "" kind?("Text") should be true 
    "" kind?("DefaultBehavior") should be true 
    "" kind?("Base") should be true 
    "" kind?("Ground") should be true 
    "" kind?("Origin") should be true 
    
    
  • - should return true if another mimic has the kind [ show source ]
    123 kind?("Mixins Comparing") should be true 
    
    
  • - should handle a cycle of mimics correctly [ show source ]
    f = Origin mimic 
    f mimic!(f) 
    f kind?("Origin") should be true 
    f = Origin mimic 
    Origin mimic!(f) 
    f kind?("Origin") should be true 
    f = Origin mimic 
    Origin mimic!(f) 
    f kind?("DefaultBehavior") should be true 
    
    
  • - should validate type of argument [ show source ]
    fn("" kind?([])) should signal(Condition Error Type IncorrectType) 
    
    
DefaultBehavior lecro
  • - should return a lecro that returns nil when called with no arguments [ show source ]
    lecro call should be nil 
    lecro call should be nil 
    
    
  • - should name itself after the slot it's assigned to if it has no name [ show source ]
    x = lecro(nil) 
    cell(:x) name should ==("x") 
    
    
  • - should not change it's name if it already has a name [ show source ]
    x = lecro(nil) 
    y = cell(:x) 
    cell(:y) name should ==("x") 
    
    
  • - should know it's own name [ show source ]
    (x = lecro(nil)) name should ==("x") 
    
    
  • - should be activatable [ show source ]
    lecro activatable should be true 
    
    
DefaultBehavior lecrox
  • - should return a lecro that returns nil when called with no arguments [ show source ]
    lecrox call should be nil 
    lecrox call should be nil 
    
    
  • - should name itself after the slot it's assigned to if it has no name [ show source ]
    x = lecrox(nil) 
    cell(:x) name should ==("x") 
    
    
  • - should not change it's name if it already has a name [ show source ]
    x = lecrox(nil) 
    y = cell(:x) 
    cell(:y) name should ==("x") 
    
    
  • - should know it's own name [ show source ]
    (x = lecrox(nil)) name should ==("x") 
    
    
  • - should not be activatable [ show source ]
    lecrox activatable should be false 
    
    
DefaultBehavior list
  • - should create a new empty list when given no arguments [ show source ]
    x = list 
    x should have kind("List") 
    x should not be same(List) 
    x should mimic(List) 
    x = list 
    x should have kind("List") 
    x should not be same(List) 
    x should mimic(List) 
    
    
  • - should create a new list with the evaluated arguments [ show source ]
    x = list(1, 2, "abc", 3 +(42)) 
    x length should ==(4) 
    x [](0) should ==(1) 
    x [](1) should ==(2) 
    x [](2) should ==("abc") 
    x [](3) should ==(45) 
    
    
DefaultBehavior loop
  • - should loop until interrupted by break [ show source ]
    x = 42 
    loop(++(x) 
      if(x ==(45), break)) 
    x should ==(45) 
    
    
DefaultBehavior macro
  • - should return a macro that returns nil when called with no arguments [ show source ]
    macro call should be nil 
    macro call should be nil 
    
    
  • - should name itself after the slot it's assigned to if it has no name [ show source ]
    x = macro(nil) 
    cell(:x) name should ==("x") 
    
    
  • - should not change it's name if it already has a name [ show source ]
    x = macro(nil) 
    y = cell(:x) 
    cell(:y) name should ==("x") 
    
    
  • - should know it's own name [ show source ]
    (x = macro(nil)) name should ==("x") 
    
    
DefaultBehavior message
  • - should return a new message [ show source ]
    message("foo") should have kind("Message") 
    
    
  • - should take a text argument [ show source ]
    message("foo") name should ==(:foo) 
    
    
  • - should take a symbol argument [ show source ]
    message(:foo) name should ==(:foo) 
    
    
DefaultBehavior method
  • - should return a method that returns nil when called with no arguments [ show source ]
    method call should be nil 
    method call should be nil 
    
    
  • - should name itself after the slot it's assigned to if it has no name [ show source ]
    (x = method(nil)) name should ==("x") 
    
    
  • - should not change it's name if it already has a name [ show source ]
    x = method(nil) 
    y = cell("x") 
    cell("y") name should ==("x") 
    
    
  • - should know it's own name [ show source ]
    (x = method(nil)) name should ==("x") 
    
    
DefaultBehavior mimic!
  • - should add a new mimic to the list of mimics [ show source ]
    f = Origin mimic 
    g = Origin mimic 
    f mimic!(g) 
    f mimics length should ==(2) 
    f mimics [](0) should ==(Origin) 
    f mimics [](1) should ==(g) 
    
    
  • - should not add a mimic that's already in the list [ show source ]
    f = Origin mimic 
    f mimic!(Origin) 
    f mimic!(Origin) 
    f mimic!(Origin) 
    f mimic!(Origin) 
    f mimics length should ==(1) 
    
    
  • - should not be able to mimic nil [ show source ]
    fn(Origin mimic mimic!(nil)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic true [ show source ]
    fn(Origin mimic mimic!(true)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic false [ show source ]
    fn(Origin mimic mimic!(false)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic symbols [ show source ]
    fn(Origin mimic mimic!(:foo)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should return the receiving object [ show source ]
    f = Origin mimic 
    f mimic!(Origin) should ==(f) 
    
    
DefaultBehavior mimics
  • - should return a list with Origin for a simple mimic [ show source ]
    Origin mimic mimics should ==([](Origin)) 
    
    
  • - should return a list with all mimics [ show source ]
    X = Origin mimic 
    Y = Origin mimic 
    Z = Origin mimic 
    y = Y mimic 
    y mimic!(X) 
    y mimic!(Z) 
    y mimics should ==([](Y, X, Z)) 
    
    
DefaultBehavior mimics?
  • - should return false if the object doesn't mimic the argument [ show source ]
    f = Origin mimic 
    Origin mimics?(f) should be false 
    f = Origin mimic 
    DefaultBehavior mimics?(f) should be false 
    f = Origin mimic 
    12 mimics?(f) should be false 
    f = Origin mimic 
    f mimics?(12) should be false 
    
    
  • - should return true if the object is the same as the argument [ show source ]
    f = Origin mimic 
    f mimics?(f) should be true 
    Origin mimics?(Origin) should be true 
    
    
  • - should return true if any of the mimics are the argument [ show source ]
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z mimics?(Origin) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z mimics?(x) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z mimics?(y) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z mimics?(z) should be true 
    f = Origin mimic 
    Origin mimic!(f) 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    z mimics?(f) should be true 
    
    
  • - should handle a cycle of mimics correctly [ show source ]
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z mimics?(Number) should be false 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z mimics?(Origin) should be true 
    x = Origin mimic 
    y = x mimic 
    z = y mimic 
    Origin mimic!(z) 
    z mimics?(Base) should be true 
    x = Origin mimic 
    x mimic!(x) 
    x mimics?(Origin) should be true 
    
    
DefaultBehavior nand
  • - should evaluate it's argument [ show source ]
    x = 41 
    30 nand(x = 42) 
    x should ==(42) 
    
    
  • - should return false if the argument evaluates to true [ show source ]
    (30 nand(42)) should be false 
    
    
  • - should return true if the argument evaluates to false [ show source ]
    (30 nand(false)) should be true 
    
    
  • - should return true if the argument evaluates to nil [ show source ]
    (30 nand(nil)) should be true 
    
    
  • - should be available in infix [ show source ]
    (30 nand(43)) should be false 
    
    
DefaultBehavior nil?
  • - should return true for nil [ show source ]
    nil nil? should be true 
    
    
  • - should return false for false [ show source ]
    false nil? should be false 
    
    
  • - should return false for true [ show source ]
    true nil? should be false 
    
    
  • - should return false for a Number [ show source ]
    123 nil? should be false 
    
    
  • - should return false for a Text [ show source ]
    "flurg" nil? should be false 
    
    
DefaultBehavior nor
  • - should not evaluate it's argument [ show source ]
    x = 41 
    30 nor(x = 42) 
    x should ==(41) 
    
    
  • - should return false [ show source ]
    30 nor(42) should be false 
    
    
  • - should be available in infix [ show source ]
    (30 nor(43)) should be false 
    
    
DefaultBehavior not
  • - should return nil for a number [ show source ]
    123 not should be nil 
    
    
  • - should return nil for a text [ show source ]
    "foo" not should be nil 
    
    
DefaultBehavior or
  • - should not evaluate it's argument [ show source ]
    x = 41 
    123 or(x = 42) 
    x should ==(41) 
    
    
  • - should return the receiver [ show source ]
    "murg" or(42) should ==("murg") 
    
    
  • - should be available in infix [ show source ]
    (444 or(43)) should ==(444) 
    
    
DefaultBehavior prependMimic!
  • - should add a new mimic to the list of mimics [ show source ]
    f = Origin mimic 
    g = Origin mimic 
    f prependMimic!(g) 
    f mimics length should ==(2) 
    f mimics [](1) should ==(Origin) 
    f mimics [](0) should ==(g) 
    
    
  • - should not add a mimic that's already in the list [ show source ]
    f = Origin mimic 
    f prependMimic!(Origin) 
    f prependMimic!(Origin) 
    f prependMimic!(Origin) 
    f prependMimic!(Origin) 
    f mimics length should ==(1) 
    
    
  • - should not be able to mimic nil [ show source ]
    fn(Origin mimic prependMimic!(nil)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic true [ show source ]
    fn(Origin mimic prependMimic!(true)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic false [ show source ]
    fn(Origin mimic prependMimic!(false)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should not be able to mimic symbols [ show source ]
    fn(Origin mimic prependMimic!(:foo)) should signal(Condition Error CantMimicOddball) 
    
    
  • - should return the receiving object [ show source ]
    f = Origin mimic 
    f prependMimic!(Origin) should ==(f) 
    
    
DefaultBehavior removeAllMimics!
  • - should return the object [ show source ]
    x = Origin mimic 
    x uniqueHexId = DefaultBehavior cell(:uniqueHexId) 
    x removeAllMimics! uniqueHexId should ==(x uniqueHexId) 
    
    
  • - should remove all mimics [ show source ]
    x = Origin mimic 
    x mimic!(Text) 
    x mimics = DefaultBehavior cell(:mimics) 
    x removeAllMimics! mimics should ==([]) 
    
    
DefaultBehavior removeMimic!
  • - should not remove something it doesn't mimic [ show source ]
    Origin mimic removeMimic!("foo") mimics should ==([](Origin)) 
    
    
  • - should return the object [ show source ]
    x = Origin mimic 
    x removeMimic!(1) should ==(x) 
    
    
  • - should remove any mimic it has [ show source ]
    x = Origin mimic 
    x mimics = DefaultBehavior cell(:mimics) 
    x removeMimic!(Origin) 
    x mimics should ==([]) 
    
    
  • - should not remove any other mimic [ show source ]
    x = Origin mimic 
    y = Origin mimic 
    x mimic!(y) 
    x removeMimic!(y) 
    x mimics should ==([](Origin)) 
    
    
DefaultBehavior return
  • - should have nil as value by default [ show source ]
    method(return) call should be nil 
    
    
  • - should take a return value [ show source ]
    method(return(42)) call should ==(42) 
    
    
DefaultBehavior same?
  • - should return false for different objects [ show source ]
    Origin mimic should not be same(Origin mimic) 
    
    
  • - should return true for the same objects [ show source ]
    x = Origin mimic 
    x should be same(x) 
    
    
DefaultBehavior send
  • - should invoke the method named [ show source ]
    x = Origin mimic do(
        foo = method(self called = true)) 
    x send(:foo) 
    x called should be true 
    
    
  • - should pass along the arguments sent [ show source ]
    x = Origin mimic do(
        foo = method(+(args), +:(kargs), self called = [](args, kargs))) 
    x send(:foo, 1, blah: :foo, "123", :foo, max: 32 +(15)) 
    x called should ==([]([](1, "123", :foo), {}(blah: :foo, max: 47))) 
    
    
  • - should return the result of the call [ show source ]
    x = Origin mimic do(
        foo = method(42 *(3))) 
    x send(:foo) should ==(126) 
    
    
DefaultBehavior set
  • - should create a new empty set when given no arguments [ show source ]
    x = set 
    x should have kind("Set") 
    x should not be same(Set) 
    x should mimic(Set) 
    x = set 
    x should have kind("Set") 
    x should not be same(Set) 
    x should mimic(Set) 
    
    
  • - should create a new set with the evaluated arguments [ show source ]
    result = set(1, 2, "abc", 3 +(42)) 
    result asList length should ==(4) 
    outside = [] 
    result each(x, 
      if(x mimics?(Text), 
        x should ==("abc"), 
        outside <<(x))) 
    outside sort should ==([](1, 2, 45)) 
    
    
DefaultBehavior size
  • - should be 0 for an empty dict [ show source ]
    dict size should ==(0)
    
  • - should be the number of pairs in dict [ show source ]
    dict(a: 1, b: 2) size should ==(2)
    
DefaultBehavior super
  • - should not be available if no super method is there [ show source ]
    fn(method(super) call) should signal(Condition Error NoSuchCell) 
    
    
  • - should return the super value if it is not method [ show source ]
    x = Origin mimic 
    x foo = 42 
    x2 = x mimic 
    x2 foo = method(super) 
    x2 foo should ==(42) 
    
    
  • - should call the super method with the same self [ show source ]
    x = Origin mimic 
    x foo = method([](self)) 
    x2 = x mimic 
    x2 foo = method(super) 
    x2 foo should ==([](x2)) 
    
    
  • - should be possible to give different arguments to super [ show source ]
    x = Origin mimic 
    x foo = method(+(args), args) 
    x2 = x mimic 
    x2 foo = method(super(1, 2, 3)) 
    x2 foo should ==([](1, 2, 3)) 
    
    
  • - should be possible to call super several times in a row [ show source ]
    Ground called_super_spec = [] 
    x = Origin mimic 
    x foo = method(called_super_spec <<("foo1")) 
    x2 = x mimic 
    x2 foo = method(called_super_spec <<("foo2") 
        super) 
    x3 = x2 mimic 
    x3 foo = method(called_super_spec <<("foo3") 
        super) 
    x3 foo 
    called_super_spec should ==([]("foo3", "foo2", "foo1")) 
    
    
DefaultBehavior syntax
  • - should name itself after the slot it's assigned to if it has no name [ show source ]
    x = syntax(nil) 
    cell(:x) name should ==("x") 
    
    
  • - should not change it's name if it already has a name [ show source ]
    x = syntax(nil) 
    y = cell(:x) 
    cell(:y) name should ==("x") 
    
    
  • - should know it's own name [ show source ]
    (x = syntax(nil)) name should ==("x") 
    
    
DefaultBehavior thaw!
  • - should be possible to call several times without effect [ show source ]
    x = Origin mimic 
    x freeze! 
    x thaw! 
    x thaw! 
    
    
  • - should unfreeze an object [ show source ]
    x = Origin mimic 
    x freeze! 
    x thaw! 
    x should not be frozen 
    
    
DefaultBehavior true?
  • - should return false for nil [ show source ]
    nil true? should be false 
    
    
  • - should return false for false [ show source ]
    false true? should be false 
    
    
  • - should return true for true [ show source ]
    true true? should be true 
    
    
  • - should return true for a Number [ show source ]
    123 true? should be true 
    
    
  • - should return true for a Text [ show source ]
    "flurg" true? should be true 
    
    
DefaultBehavior tuple
  • - should return the right kind of tuple for up to nine elements [ show source ]
    tuple should be same(Tuple) 
    tuple(1, 2) should mimic(Tuple Two) 
    tuple(1, 2, 3) should mimic(Tuple Three) 
    tuple(1, 2, 3, 4) should mimic(Tuple Four) 
    tuple(1, 2, 3, 4, 5) should mimic(Tuple Five) 
    tuple(1, 2, 3, 4, 5, 6) should mimic(Tuple Six) 
    tuple(1, 2, 3, 4, 5, 6, 7) should mimic(Tuple Seven) 
    tuple(1, 2, 3, 4, 5, 6, 7, 8) should mimic(Tuple Eight) 
    tuple(1, 2, 3, 4, 5, 6, 7, 8, 9) should mimic(Tuple Nine) 
    tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) should mimic(Tuple Many) 
    tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) should mimic(Tuple Many) 
    
    
  • - should add accessor methods for Tuple Many tuples [ show source ]
    tx = tuple(1, 2, 3, 4, 5, 6, 7, 8, "9", 42, "blarg") 
    tx _9 should ==("9") 
    tx _10 should ==(42) 
    tx _11 should ==("blarg") 
    
    
  • - should set the elements correctly [ show source ]
    tx = tuple(5, 4, 3, 2, 1) 
    tx first should ==(5) 
    tx _1 should ==(5) 
    tx second should ==(4) 
    tx _2 should ==(4) 
    tx third should ==(3) 
    tx _3 should ==(3) 
    tx fourth should ==(2) 
    tx _4 should ==(2) 
    tx fifth should ==(1) 
    tx _5 should ==(1) 
    
    
DefaultBehavior uniqueHexId
  • - should return different ids for different objects [ show source ]
    Origin mimic uniqueHexId should not ==(Origin mimic uniqueHexId) 
    
    
  • - should return the same id for the same object [ show source ]
    x = Origin mimic 
    x uniqueHexId should ==(x uniqueHexId) 
    
    
DefaultBehavior unless
  • - should evaluate it's first element once [ show source ]
    x = 42 
    unless(++(x)) 
    x should ==(43) 
    
    
  • - should return it's second argument if the first element evaluates to false [ show source ]
    unless(false, 42, 43) should ==(42) 
    
    
  • - should return it's third argument if the first element evaluates to true [ show source ]
    unless(true, 42, 43) should ==(43) 
    
    
  • - should return the result of evaluating the first argument if there are no more arguments [ show source ]
    unless(44) should ==(44) 
    
    
  • - should return the result of evaluating the first argument if it is true and there are only two arguments [ show source ]
    unless(true, 13) should be true 
    
    
  • - should assign the test result to the variable it [ show source ]
    unless(42, nil, it) should ==(42) 
    unless(nil, it, 42) should be nil 
    unless(false, it, 42) should be false 
    unless("str", it, 42) should ==(42) 
    
    
  • - should have a lexical context for the it variable [ show source ]
    unless(42, nil, fn(it)) call should ==(42) 
    
    
  • - should be possible to nest it variables lexically [ show source ]
    unless(42, nil, [](it, unless(13, nil, [](it, unless(nil, it, 44), it)))) should ==([](42, [](13, nil, 13))) 
    
    
DefaultBehavior until
  • - should not do anything if initial argument is true [ show source ]
    x = 42 
    until(true, x = 43) 
    x should ==(42) 
    
    
  • - should loop until the argument becomes true [ show source ]
    x = 42 
    until(x ==(45), ++(x)) 
    x should ==(45) 
    
    
  • - should return the last statement value [ show source ]
    x = 42 
    until(x ==(43), ++(x) 
      "blurg") should ==("blurg") 
    
    
  • - should be interrupted by break [ show source ]
    x = 42 
    until(x ==(50), ++(x) 
      if(x ==(45), break)) 
    x should ==(45) 
    
    
  • - should be continued by continue [ show source ]
    count = 0 
    x = 42 
    until(x ==(50), ++(count) 
      if(x ==(45), x = 47 
        continue) 
      ++(x) 
      ) 
    x should ==(50) 
    count should ==(7) 
    
    
  • - should return nil if no arguments provided [ show source ]
    until should be nil 
    
    
DefaultBehavior while
  • - should not do anything if initial argument is false [ show source ]
    x = 42 
    while(false, x = 43) 
    x should ==(42) 
    
    
  • - should loop until the argument becomes false [ show source ]
    x = 42 
    while(x <(45), ++(x)) 
    x should ==(45) 
    
    
  • - should return the last statement value [ show source ]
    x = 42 
    while(x <(43), ++(x) 
      "blurg") should ==("blurg") 
    
    
  • - should be interrupted by break [ show source ]
    x = 42 
    while(x <(50), ++(x) 
      if(x ==(45), break)) 
    x should ==(45) 
    
    
  • - should be continued by continue [ show source ]
    count = 0 
    x = 42 
    while(x <(50), ++(count) 
      if(x ==(45), x = 47 
        continue) 
      ++(x) 
      ) 
    x should ==(50) 
    count should ==(7) 
    
    
  • - should return nil if no arguments provided [ show source ]
    while should be nil 
    
    
DefaultBehavior with
  • - should just mimic an object if no arguments given [ show source ]
    Origin with cellNames should ==([]) 
    
    
  • - should set the given keywords as cells [ show source ]
    Origin with(foo: 13) cellNames should ==([](:foo)) 
    Origin with(foo: 13) cells should ==({}(foo: 13)) 
    Origin with(foo: 13, bar: 14) cellNames should ==([](:foo, :bar)) 
    Origin with(foo: 13, bar: 14) cells should ==({}(foo: 13, bar: 14)) 
    
    
DefaultBehavior xor
  • - should evaluate it's argument [ show source ]
    x = 41 
    30 xor(x = 42) 
    x should ==(42) 
    
    
  • - should return false if the argument is true [ show source ]
    (30 xor(true)) should be false 
    
    
  • - should return true if the argument is false [ show source ]
    (30 xor(false)) should be true 
    
    
  • - should return true if the argument is nil [ show source ]
    (30 xor(nil)) should be true 
    
    
  • - should be available in infix [ show source ]
    (30 xor(43)) should be false 
    
    
DefaultBehavior {}
  • - should create a new empty dict when given no arguments [ show source ]
    x = {} 
    x should be kind("Dict") 
    x should not be same(Dict) 
    x should mimic(Dict) 
    
    
  • - should create a new dict with the evaluated arguments [ show source ]
    result = {}(1 =>(2), "abc" =>(3 +(42)), :foo =>(123), :bar =>("x")) 
    result asList length should ==(4) 
    
    
  • - should create a new dict with keyword arguments [ show source ]
    result = {}(abc: 2, foo: 3 +(42), bar: 123, quux: "x") 
    result asList length should ==(4) 
    
    
  • - should take arguments that are not keyword or pairs and add nil as value for them [ show source ]
    {}(123, "foo", 13 +(2), :bar) should ==({}(123 =>(nil), "foo" =>(nil), 15 =>(nil), :bar =>(nil))) 
    
    
  • - should take keyword arguments without a next pointer and add nil as value for them [ show source ]
    {}(foo:, bar:, quux:) should ==({}(:foo =>(nil), :bar =>(nil), :quux =>(nil))) 
    
    
DefaultBehavior |=
  • - should call | and then assign the result of this call to the same name [ show source ]
    x = 5 
    |=(x, 6) 
    x should ==(7) 
    x = 5 
    |=(x, 4) 
    x should ==(5) 
    
    
  • - should work with a place [ show source ]
    x = [](5) 
    x |=([](0), 6) 
    x [](0) should ==(7) 
    
    
DefaultBehavior ||
  • - should not evaluate it's argument [ show source ]
    x = 41 
    123 ||(x = 42) 
    x should ==(41) 
    
    
  • - should return the receiver [ show source ]
    "murg" ||(42) should ==("murg") 
    
    
  • - should be available in infix [ show source ]
    (444 ||(43)) should ==(444) 
    
    
DefaultBehavior ||=
  • - should assign a cell if it doesn't exist [ show source ]
    ||=(test_double_pipe_equals, 42) 
    test_double_pipe_equals should ==(42) 
    
    
  • - should assign a cell if it is nil [ show source ]
    x = nil 
    ||=(x, 42) 
    x should ==(42) 
    
    
  • - should assign a cell if it is false [ show source ]
    x = false 
    ||=(x, 42) 
    x should ==(42) 
    
    
  • - should not assign a cell that exist [ show source ]
    x = 43 
    ||=(x, 42) 
    x should ==(43) 
    
    
  • - should work with a place [ show source ]
    x = [](1, 3) 
    x ||=([](1), 42) 
    x should ==([](1, 3)) 
    x = [](2, 3) 
    x ||=([](2), 42) 
    x should ==([](2, 3, 42)) 
    x = [](3, nil) 
    x ||=([](1), 42) 
    x should ==([](3, 42)) 
    x = [](4, false) 
    x ||=([](1), 42) 
    x should ==([](4, 42)) 
    
    
DefaultBehavior ?
  • - should be possible to create a new LexicalBlock with it [ show source ]
    ? call should be nil 
    
    
  • - should be possible to create a new LexicalBlock with it that returns a value [ show source ]
    ?(42) call should ==(42) 
    
    
DefaultBehavior ?
  • - should be possible to create a new LexicalBlock with it [ show source ]
    ? call should be nil 
    
    
  • - should be possible to create a new LexicalBlock with it that returns a value [ show source ]
    ?(42) call should ==(42) 
    
    
DefaultBehavior ?
  • - should return a new empty set [ show source ]
    x = ? 
    x should have kind("Set") 
    x should not be same(Set) 
    x should mimic(Set) 
    x = ? 
    x should have kind("Set") 
    x should not be same(Set) 
    x should mimic(Set) 
    
    
Inactive cells (details)
kind = "DefaultBehavior"
Active cells (details)
cellDescriptionDict()

returns a dict containing each cell and it's corresponding description

method(
  cellNames = cell(:self) cellNames sort 
  cellDescs = cellNames map(name, cell(:self) cell(name) notice) 
  {} addKeysAndValues(cellNames, cellDescs))
DefaultBehavior cellDescriptionDict
  • - should return an empty dict for an object without cells [ show source ]
    Origin mimic cellDescriptionDict should ==({}) 
    
    
  • - should return a dict with an element for something more complicated [ show source ]
    x = Origin mimic 
    x foo = :bar 
    x cellDescriptionDict should ==({}(foo: ":bar")) 
    
    
  • - should return a dict with an element for a method [ show source ]
    x = Origin mimic 
    x foo = method(bar) 
    x cellDescriptionDict should ==({}(foo: "foo:method(...)")) 
    
    
  • - should return a dict with more than one element [ show source ]
    x = Origin mimic 
    x y = 42 
    x z = 22 
    x cellDescriptionDict should ==({}(y: "42", z: "22")) 
    
    
cellSummary()

returns a representation of the current object that includes information about it's cells

method(
  cellDescriptions = cellDescriptionDict 
  vals = cellDescriptions keys sort map(k, list(k, cellDescriptions [](k))) 
  " #{cell(:self) notice}:
%*[  %-28s = %s\n%]" format(vals))
DefaultBehavior cellSummary
  • - should use notice for the first line [ show source ]
    x = Origin mimic 
    x uniqueHexId = "0x3FF420" 
    x cellSummary [](0 ...(18)) should ==(" Origin_0x3FF420:\n") 
    
    
  • - should use cellDescriptionDict for the data [ show source ]
    x = Origin mimic 
    x uniqueHexId = "0x3FF420" 
    x cellDescriptionDict = {}(foo: "bar") 
    x cellSummary [](0 ...(57)) should ==(" Origin_0x3FF420:\n  foo                          = bar\n") 
    
    
genSym()

returns a new, unique symbol every time called. The symbol will be quite unreadable, and uses a closure to generate a new number every time that is independent from external state.

fnx(
  :("#<GS#{++(n)}>"))
DefaultBehavior genSym
  • - should generate a new thing every time called [ show source ]
    genSym should not ==(genSym) 
    
    
  • - should generate a symbol [ show source ]
    genSym should have kind("Symbol") 
    
    
inspect()

returns a longer description of the receiver, in general including cell information

method(
  cellSummary)
DefaultBehavior inspect
  • - should use cellSummary [ show source ]
    x = Origin mimic 
    x cellSummary = "blarg" 
    x inspect should ==("blarg") 
    
    
notice()

returns a short text description of the receiver

method(
  if(currentMessage Origin ==(cell(:self)), 
    "Origin", 
    if(currentMessage Ground ==(cell(:self)), 
      "Ground", 
      "#{cell(:self) kind}_#{cell(:self) uniqueHexId}" 
      )))
DefaultBehavior notice
  • - should return the kind and hex string for a simple object from Origin [ show source ]
    x = Origin mimic 
    x uniqueHexId = "0x3FF420" 
    x notice should ==("Origin_0x3FF420") 
    
    
  • - should handle a new kind [ show source ]
    Ground Blarg = Origin mimic 
    x = Blarg mimic 
    x uniqueHexId = "0x3FF420" 
    x notice should ==("Blarg_0x3FF420") 
    
    
use(module false)

takes one or more evaluated string argument. will import the files corresponding to each of the strings named based on the Ioke loading behavior that can be found in the documentation for the loadBehavior cell on System.

DefaultBehavior use
  • - should load a file with an absolute file name [ show source ]
    result = use(System currentDirectory +("/_test2/loadx")) 
    result should be true 
    loadx_loaded should ==(42) 
    
    
  • - should load a file in the same directory [ show source ]
    result = use("test/load1") 
    result should be true 
    val should ==(42) 
    
    
  • - should load a file in the same directory when explicitly have suffix [ show source ]
    result = use("test/load2.ik") 
    result should be true 
    val2 should ==(42) 
    
    
  • - should not load something that's already been loaded [ show source ]
    Ground vex = 13 
    use("test/load3") should be true 
    use("test/load3") should be false 
    vex should ==(14) 
    
    
  • - should search the added load paths [ show source ]
    System loadPath <<("test/sub_load") 
    use("foo1") 
    Ground fooHasBeenLoaded should ==(42) 
    
    
  • - should raise exception if it can't find something [ show source ]
    fn(use("blarg")) should signal(Condition Error Load)