# List, Array, Set, Dict literals dynamic if heterogenous type and not object # ticket:176 class DynLitSeq def main .testList .testArray .testSet .testDict .testStream def testList a = 'aoeu' to Object b = 5 to Object l = [a to String, b to int] # List x = l[0] y = l[1] assert x.length == 4 assert y * 2 == 10 l1 = ['ae', 'aeiaei'] # List x1 = l1[0] assert x1.length == 2 assert l1[1].length == 6 def testArray a = 'aoeu' to Object b = 5 to Object l = @[a to String, b to int] # array of HeterogenousObject x = l[0] y = l[1] assert x.length == 4 assert y * 2 == 10 def testSet a = 'aoeu' to Object b = 5 to Object s = {a to String, b to int} # Set assert a in s assert b in s assert a to String in s assert b to int in s assert 'z' not in s l = s.toList x = l[0] y = l[1] assert x.length == 4 assert y * 2 == 10 def testDict a = 'aoeu' to Object b = 5 to Object #l as Dictionary = {0:a to String, 1:b to int} l = {0:a to String, 1:b to int} # Dict x = l[0] y = l[1] assert x.length == 4 assert y * 2 == 10 def testStream stuff as dynamic* stuff = [1, 'x'] count = 0 for x in stuff assert x in {1, 'x'} count += 1 assert count == 2 objStm as Object* objStm = [1, 'x'] to List # Heterogeneous lists are List now #objStm = [1 to Object, 'x' to Object] # also OK count = 0 for x in objStm assert x in {1, 'x'} count += 1 assert count == 2