// // TEST CASES for namespacing // #include "Moo.moo". class MyObject(Object) { } class MyObject.Donkey (MyObject) { var(#class) Cat := MyObject, Party := 5555, X := 'test string'. method(#class) v { ^901982 } } pooldic MyObject.Code { FAST := 20, FASTER := 40, FASTER2X := self.FASTER, FASTER3X := #(self.FAST self.FASTER self.FASTER2X #(MyObject.Donkey selfns.Donkey self.FAST FASTER) FASTER2X) } class MyObject.Donkey.Party (MyObject.Donkey) { } class MyObject.Donkey.Party.Party (MyObject.Donkey) { } extend MyObject.Donkey.Party { method(#class) party1 { ^Party } method(#class) party2 { ^selfns.Party } method(#class) party3 { ^self.Party } method(#class) party4 { ^selfns.Party.Party } method(#class) cat1 { ^Cat } method(#class) code1 { ^MyObject.Code } } class MyObject.System.Donkey (MyObject) { var t1, t2. method t1 { ^t1 } method(#class) v { ^89123 } } class MyObject.System.Horse (Donkey) { method(#class) myns1 { ^selfns } method(#class) myns2 { [^selfns] value } method(#class) donkey1 { ^Donkey } method(#class) donkey2 { ^selfns.Donkey } // should return same as MyObject.System.Donkey method(#class) donkey3 { ^MyObject.Donkey } method(#class) horse1 { ^Horse } method(#class) horse2 { ^selfns.Horse } } pooldic XX { Horse := MyObject.System.Horse, Party := MyObject.Donkey.Party, AAAA := 'AAAAAAAAAAAAAAAAAAAAAAAAA', FFFF := 'FFFFFFFFFFFFFFFFFFFFFFFFF' } class MyObject.System.System (selfns.Donkey) { var(#classinst,#get,#set) a, b, c. var(#get) ii := 0, jj := 0. } class MyObject.System.System.System (MyObject.System.System) { var(#classinst,#get) d, dd, ddd. var(#class,#get) KING := #KING. } class MyObject.System.System.System.System (MyObject.System.System.System) { var(#classinst,#get) e, f := XX.FFFF. var(#get) kk := #KK. } class MyObject.System.Stallion (selfns.Donkey) { import System.XX. var(#set,#get) x := MyObject.Code.FASTER3X, rvd. var yyy. var(#set,#get) zebra, qatar := MyObject.Code.FASTER2X. method(#class) party { ^Party } method(#class) system1 { ^System } // Single word. can be looked up in the current workspace. method(#class) system2 { ^System.System } // Dotted. The search begins at the top. } extend MyObject { // TODO: support import in extend?? method(#class) makeBlock(a,b) { ^[:x | a * x + b] } method(#class) testMakeBlock { |a b | a := self makeBlock (12, 22). b := self makeBlock (99, 4). ^(a value: 5) * (b value: 6). // (12 * 5 + 22) * (99 * 6 + 4) => 49036 } method(#class) testBigintDiv: divd_base divisor: divr_base count: count { | i q r divd divr ubound | i := 1. ubound := i + count. while (i < ubound) { divd := divd_base * i. divr := divr_base * i. q := divd div: divr. r := divd rem: divr. if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }. divd := divd_base * i. divr := divr_base. q := divd div: divr. r := divd rem: divr. if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }. divd := divd_base. divr := divr_base * i. q := divd div: divr. r := divd rem: divr. if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }. divd := divd_base * i * i. divr := divr_base * i. q := divd div: divr. r := divd rem: divr. if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }. i := i + 1. }. ^true } method(#class) main { | tc limit | tc := ##( // 0 - 4 [MyObject.Donkey v == 901982], [selfns.MyObject.Donkey v == 901982], [MyObject.System.Donkey v == 89123], [MyObject.System.Horse v == 89123], [selfns.MyObject.System.Donkey v == 89123], // 5 - 9 [MyObject.System.Horse donkey1 == MyObject.System.Donkey], [MyObject.System.Horse donkey2 == MyObject.System.Donkey], [MyObject.System.Horse donkey2 v == 89123], [MyObject.System.Horse donkey3 v == 901982], [MyObject.System.Horse horse1 == MyObject.System.Horse], // 10 - 14 [MyObject.System.Horse horse2 == MyObject.System.Horse], [MyObject.System.Horse superclass == MyObject.System.Donkey], [MyObject.System.Donkey superclass == MyObject], [selfns == System nsdic], [MyObject.System.Horse myns1 == MyObject.System], // 15 - 19 [MyObject.System.Horse myns2 == MyObject.System], [MyObject.System == self.System], [MyObject.System.Donkey == self.System.Donkey], [MyObject.System.Stallion superclass == self.System.Donkey], [MyObject.Donkey.Party party1 == 5555], // 20 - 24 [MyObject.Donkey.Party party2 == MyObject.Donkey.Party], [MyObject.Donkey.Party party3 == 5555], [MyObject.Donkey.Party party4 == MyObject.Donkey.Party.Party], [MyObject.Donkey.Party cat1 == MyObject], [MyObject.Code.FASTER2X == 40], // 25 - 29 [MyObject.Code.FASTER2X == MyObject.Code.FASTER], [((MyObject.Code.FASTER3X at: 3) at: 1) == MyObject.Donkey], [MyObject.System.Stallion new x == MyObject.Code.FASTER3X], [MyObject.System.Stallion party == MyObject.Donkey.Party], [MyObject.System.Stallion system1 == MyObject.System.System], // 30 - 34 [MyObject.System.Stallion system2 == System.System], [MyObject.System.System.System.System f == XX.FFFF], [MyObject.System.System a == XX.AAAA], [MyObject.System.System.System.System a == nil] , [MyObject.System.System.System.System new kk == #KK], // 35 - 39 [MyObject.System.System.System KING == #KING], [self testMakeBlock == 49036], [ ((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = 65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033 ], [ "%d" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033' ], [ "%#b" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '2r100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001' ], // 40 - 44 [ "%#x" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '16r20000000000000000000000000000000000000000000000000000000000000000000000000001' ], [ (7 div: -3) = -2 ], [ (7 rem: -3) = 1 ], [ (7 mdiv: -3) = -3 ], [ (7 mod: -3) = -2 ], // 45-49 [ ([ (7 div: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 rem: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 mdiv: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 mod: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ (270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) = 5 ], // 50-54 [ (270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) = 5], [ (270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], // 55-59 [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) = 4184734490355220618401938634485367707982 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ], [ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ], // 60-64 [(100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = 100213123891273912837891273189237], [(-100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(-100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = -100213123891273912837891273189237], [(-100213123891273912837891273189237 mdiv: 1238971238971894573289472398477891263781263781263) = -1], // 65-69 [(-100213123891273912837891273189237 mod: 1238971238971894573289472398477891263781263781263) = 1238971238971894473076348507203978425889990592026], [(-123897123897189421321312312321312312132 div: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 rem: -123897123897189421321312312321312312132) = 0], [(-123897123897189421321312312321312312132 mdiv: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 mod: -123897123897189421321312312321312312132) = 0], // 70-74 [ (-0.1233 * 999999.123) = -123299.8918 ], [ (-0.1233 * 999999.123) asString = '-123299.8918' ], [ (-0.1233 - -0.123) = -0.0003 ], [ (-0.1233 - -0.123) asString = '-0.0003' ], [ (1.234 - 1.234) = 0 ], // 0.000 // 75-79 [ (10.12 * 20.345) = 205.891 ], [ (10.12 mlt: 20.345) = 205.89 ], [ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ], [ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ], [ 10 scale = 0 ], // 80-84 [ 10.0 scale = 1 ], [ 10.00 scale = 2 ], [ (10 scale: 1) = 10.0 ], [ (10 scale: 1) scale = (10.1 scale) ], [ (10 scale: 2) scale = (10.11 scale) ], // 85-89 [ ((-10.19 scale: 3) scale) = (10.199 scale) ], [ ((-10.19 scale: 0) scale) = (10 scale) ], [ (-9p10 scale) = (-10.000000000 scale) ], [ (-9p10.123 scale) = (-10.123000000 scale) ], [ (+3p100.1 + 16rffff + +5p1.22 + -5p1.223) = 65635.09700 ], // 90-94 [ (30p2123.12 asString) = '2123.120000000000000000000000000000' ], [ (+30p2123.12 asString) = '2123.120000000000000000000000000000' ], [ (-30p2123.12 asString) = '-2123.120000000000000000000000000000' ], [ (811306333091350399588761 div: 16) = 50706645818209399974297 ], [ (811306333091350399588761 mdiv: 16) = 50706645818209399974297 ], // 95-99 [ (811306333091350399588761 rem: 16) = 9 ], [ (811306333091350399588761 mod: 16) = 9 ], [ (811306333091350399588761 div: 128) = 6338330727276174996787 ], [ (811306333091350399588761 mdiv: 128) = 6338330727276174996787 ], [ (811306333091350399588761 rem: 128) = 25 ], // 100-104 [ (811306333091350399588761 mod: 128) = 25 ], [ (-811306333091350399588761 div: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 mdiv: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 rem: -16) = -9 ], [ (-811306333091350399588761 mod: -16) = -9 ], // 105-109 [ (-811306333091350399588761 div: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 mdiv: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 rem: -128) = -25 ], [ (-811306333091350399588761 mod: -128) = -25 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -1024) = 7922913409095218745983995988652160870400128212219627901 ], // 110-114 [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -1024) = 7922913409095218745983995988652160870400128212219627901 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65535) = 123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65535) = 123797411015693964994088836383303772507663558240831600 ], // 115-119 [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65536) = -63071 ], // 120-124 [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65536) = -63071 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 65535) = -123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 65535) = -123797411015693964994088836383303772507663558240831601 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 65535) = 304 ], // 125-129 [ (65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = -1 ], [ (65535 rem: -8113063330913503995887611892379812731289731289312898971231) = 65535 ], [ (65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -8113063330913503995887611892379812731289731289312898905696 ], [ (-65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], // 130-134 [ (-65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 rem: -8113063330913503995887611892379812731289731289312898971231) = -65535], [ (-65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 div: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 mdiv: 8113063330913503995887611892379812731289731289312898971231) = -1 ], // 135-139 [ (-65535 rem: 8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 mod: 8113063330913503995887611892379812731289731289312898971231) = 8113063330913503995887611892379812731289731289312898905696 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = 236121219667649827777862429280643489074710852271 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = -236121219667649827777862429280643489074710852271 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 34359738368) = -236121219667649827777862429280643489074710852272 ], // 140-144 [ (-8113063330913503995887611892379812731289731289312898971231 rem: 34359738368) = -31040337503 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 34359738368) = 3319400865 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 18446744073709551615) = -439810044444445199874532569660475732947 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 18446744073709551615) = -439810044444445199874532569660475732948 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 18446744073709551615) = -16637658201046411826 ], // 145-149 [ (-8113063330913503995887611892379812731289731289312898971231 mod: 18446744073709551615) = 1809085872663139789 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971231) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971232) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971232) = 8113063330913503995887611892379812731289731289312898971231 ], // 150-154 [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ], [ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ], [ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ], // 155-159 [ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ], [ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ], [ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ], [ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ], [ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ], // 160-164 [ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ], [ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ], [ self testBigintDiv: 265804060782114895959697138188904455994 divisor: 713053462628379038341886861235 count: 1], // ========================= [ | k | k := String new. (##( 1 + 2, -21391239218392 * +291382913821, 19p10 div: 3 ) asOrderedCollection) doWithIndex: [:each :index | k := k & (index asString) & '=>' & (each asString) & ' '. ]. k = '0=>3 1=>-6233041613697111534195832 2=>3.3333333333333333333 '. ], [ | k | k := #('str1' 'str2' 'str3' 'str4' 'str5' 'str1' 'str2') asSet. //k do: [:each | each dump]. if ((k includes: 'str1') and (k includes: 'str3') and ((k includes: 'str9') not)) { true } else { false } ], [ | b | b := [:n | (n > 0) ifTrue: [ n * (b value: n - 1)] ifFalse: [1]]. (b value: 3) == 6 ], [ | b | b := [:n | (n > 0) ifTrue: [ (b value: n - 1) * n] ifFalse: [1]]. (b value: 3) == 6 ] ). limit := tc size. MyObject.System.System a: XX.AAAA. 0 priorTo: limit by: 1 do: [ :idx | | tb | tb := tc at: idx. System log(System.Log.INFO, idx asString, (if (tb value) { " PASS" } else { " FAIL" }), "\n"). ]. [ 10 dump. [20 dump] value; value; ] value; value. } }