This file is indexed.

/usr/share/gnu-smalltalk/unsupported/t.st is in gnu-smalltalk-common 3.2.5-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
"======================================================================
|
|   Generic test bed and source of interesting bits of code for GNU 
|   Smalltalk.
|
|
 ======================================================================"


"======================================================================
|
| Copyright 1988-92, 1994-95, 1999, 2000 Free Software Foundation, Inc.
| Written by Steve Byrne.
|
| This file is part of GNU Smalltalk.
|
| GNU Smalltalk is free software; you can redistribute it and/or modify it
| under the terms of the GNU General Public License as published by the Free
| Software Foundation; either version 2, or (at your option) any later version.
| 
| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
| FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
| details.
| 
| You should have received a copy of the GNU General Public License along with
| GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
|
 ======================================================================"

stdout nextPutAll: ('Welcome to GNU Smalltalk [', Version, ']

This file contains a wealth of goodies, not all packaged neatly.
It sort of grows by accretion, so you''re likely to find most
anything in here.
' ).

ObjectMemory quit!

"| q |
    q := SharedQueue new.
    q nextPut: 'foo'.
    q nextPut: 'bar'.
    q next printNl.
    q next printNl.
    q next printNl   ""Should print no-runnable-proceses""
!
"

Object withAllSubclasses do: 
    [ :subclass | (subclass name notNil and: [ subclass comment isNil ])
		      ifTrue: [ subclass name print.
				' has no comment.' printNl ] 
		      ]

!

ObjectMemory quit!



!Object methodsFor: 'testing'!

test
    | x |
      x := [ :dummy | "thisContext inspect.
		  Smalltalk backtrace."
		    thisContext backit ].
"    x inspect."
    x value: 3
!

backit
    | n context | 
    n := 0.
    context := thisContext.
    [ context notNil ] whileTrue: [ n := n + 1. context := context parentContext ].
    context := thisContext.
    n to: 1 by: -1 do: 
	[ :i | context receiver print.
	       '>>' print.
	       context selector printNl.
	       context := context parentContext ].
! !

!BlockContext methodsFor: 'debugging'!

callers
    self inspect.
    caller notNil
	ifTrue: [ caller callers ]
!

parentContext
    ^caller
!

selector
    ^selector
!

receiver
    ^'[] in ', home class name
! !

!MethodContext methodsFor: 'debugging'!

callers
    self inspect.
    sender notNil 
	ifTrue: [ sender callers ]
!

parentContext
    ^sender
!

receiver
    ^receiver class name
!

selector
    ^selector
! !

3 test!

ObjectMemory quit!


"| count |

SymbolTable do: 
    [ :elt | elt printString.
	     "Character nl print
	     count := 0.
	     elt notNil ifTrue: [ elt do: [ :x | count := count + 1 ]].
	     count timesRepeat: [ 'x' print ].
	     Character nl print" ] !


ObjectMemory quit!
"

"| d days |
d := Date new.
1 to: 70 do:
    [ :year | days := year * 365.
    	      days - 5 to: days + 5 do:
		 [ :i | d setDays: i.
			d printString ] ]
!

ObjectMemory quit!"

Date edit: #computeDateParts:!

"| pipe |
    pipe := FileStream popen: 'lpr -Pelab' dir: 'w'.
    FileStream fileOutOn: pipe.
    FileStream class fileOutOn: pipe.
    pipe close!"



| d days |
d := Date new.
1 to: 70 do:
    [ :year | days := year * 365.
    	      '----------' printNl.
    	      days - 5 to: days + 5 do:
		 [ :i | d setDays: i.
			d printNl ] ]
!

Date today printNl!

| f |
    f := ReadWriteStream on: (String new: 0).
    'foo on you' printOn: f.
    f position: 3.
    '123456789' printOn: f.
    f skip: -1.
    f next printNl.
    f contents printNl.
    f reset.
    'test[]' printOn: f.
    f contents printNl!

16r3F0000000 printNl!

ObjectMemory quit!

!Date methodsFor: 'rambo'!

computeDateParts: aBlock
    | yearInteger tempDays monthIndex daysInMonth |
    tempDays := days - (days // 1460) "4*365"
    	    	    + (days // 36500) "100*365"
		    - (days // 146000). "400*365"
    yearInteger := tempDays // 365.
    tempDays := days - (yearInteger * 365)
		    - (yearInteger // 4)
		    + (yearInteger // 100)
		    - (yearInteger // 400)
		    + 1.
    yearInteger := yearInteger + 1901.
    monthIndex := 1.
    [ monthIndex < 12
    	and: [ daysInMonth := Date daysInMonthIndex: monthIndex
	    	    	    	  forYear: yearInteger.
    	       tempDays > daysInMonth ] ] whileTrue:
    	[ monthIndex := monthIndex + 1.
	  tempDays := tempDays - daysInMonth ].
    ^aBlock value: yearInteger value: monthIndex value: tempDays
! !

| d days |
d := Date new.
1 to: 70 do:
    [ :year | days := year * 365.
    	      '----------' printNl.
    	      days - 5 to: days + 5 do:
		 [ :i | d setDays: i.
			d printNl ] ]
!

Date today printNl!

| f |
    f := ReadWriteStream on: (String new: 0).
    'foo on you' printOn: f.
    f position: 3.
    '123456789' printOn: f.
    f skip: -1.
    f next printNl.
    f contents printNl.
    f reset.
    'test[]' printOn: f.
    f contents printNl!

16r3F0000000 printNl!


| d days |
d := Date new.
1 to: 70 do:
    [ :year | days := year * 365.
    	      '----------' printNl.
    	      days - 3 to: days + 10 do:
		 [ :i | d setDays: i.
			d printNl ] ]
!

Date today printNl!

| f |
    f := ReadWriteStream on: (String new: 0).
    'foo on you' printOn: f.
    f position: 3.
    '123456789' printOn: f.
    f skip: -1.
    f next printNl.
    f contents printNl.
    f reset.
    'test[]' printOn: f.
    f contents printNl!

Object withAllSubclasses do:
    [ :aClass | aClass fileOutOn: stdout ]!

!Bag methodsFor: 'enumerating the elements of a collection'!

occurrencesOf: anObject
    ^contents at: anObject ifAbsent: [ ^0 ]
!

size
    | count |
    count := 0.
    contents printNl.
    contents do: [ :element | count := count + element ].
    ^count
!

do: aBlock
    contents associationsDo:
      [ :assoc | assoc value printNl
"  assoc value timesRepeat: [ aBlock value: assoc key ]" ]
! !

| b |
    b := Bag new.
    (b occurrencesOf: 'foo' ) printNl.
    b size printNl.
    b basicSize printNl.
    b add: 'foo'.
    b add: 'bar'.
    b add: 'quem.'.
    b do: [ :value | 'value is ' print. value printNl ]
!

!ClassDescription methodsFor: 'filing'!

fileOutOn: aFileStream
    | categories |
    categories := Bag new.
    methodDictionary do:
	[ :method | categories add: (method methodCategory) ].
'categories....' printNl.
    categories inspect.
    categories do:
	[ :category | category printNl "self emitCategory: category toStream: aFileStream" ]
! !

!ClassDescription methodsFor: 'private'!

emitCategory: category toStream: aFileStream
    ' methodsFor: ''' printOn: aFileStream.
    category printOn: aFileStream.
    '''

'   printOn: aFileStream.
    methodDictionary do:
	[ :method | (method methodCategory) = category
			ifTrue: [ method methodSourceString
				      printOn: aFileStream.
				  '!

'				 printOn: aFileStream ] ].
    '!

'   printOn: aFileStream

! !

Object fileOutOn: stdout!


"Boolean selectors do: [ :selectors | selectors printNl ].
'
after ' printNl.
Boolean copyCategory: 'basic' from: True.
Boolean selectors do: [ :selectors | selectors printNl ]!"

"| method newMethod |
    method := CompiledMethod compiledMethodAt: #bytecodeAt:.
    'Original' printNl.
    method inspect.
    '

Cheap imitation' printNl.
    newMethod := Object copy: #bytecodeAt:
		     from: CompiledMethod
		     classified: 'rambo'.
    (Object compiledMethodAt: #bytecodeAt:) methodCategory printNl.

    method methodCategory printNl
!

ObjectMemory quit!"


"| j |
    j := 0.
    1 to: 20000 do: [ :i | j := j + i ]!

ObjectMemory quit!"

"Smalltalk gcMessage: false!"

!ClassDescription methodsFor: 'test'!

printSubclassMethods
    | mySubclasses |
    self name printNl.
    instanceVariables notNil
	ifTrue: [ 'Instance variables: ' print.
		  instanceVariables do: [ :var | var print.
						 ' ' print ].
		  Character nl print].
    '-----------------------------------------------' printNl.
    self selectors asSortedCollection do:
	[ :selector |
	  (self compiledMethodAt: selector) methodSourceString printNl.
	 '' printNl ].
    mySubclasses := self subclasses asSortedCollection:
    	    		[ :a :b | (a name isNil or: [ b name isNil ])
    	    	    	    	      ifTrue: [ true ]
		    	    	      ifFalse: [ a name <= b name ] ].
    mySubclasses do:
    	[ :subclass | subclass class ~~ Metaclass
	    	    	ifTrue: [ subclass printSubclassMethods ] ]
! !


Object printSubclassMethods!

ObjectMemory quit!
""
!Collection methodsFor: 'test'!

printSorted
    self asSortedCollection do:
    	[ :element | '    ' print. element printNl ]
! !
"
Smalltalk at: #BasicClassSelectors put: Class allSelectors!

"
!Behavior methodsFor: 'test'!

printInheritedSelectors
    | sels |
    sels := self allSelectors.
    sels removeAll: self selectors.
    sels printSorted
!
"
printNewSelectors
    | sels |
    sels := self allSelectors.
    sels removeAll: BasicClassSelectors.
    sels printSorted

!"!
Smalltalk monitor: true.
Class printInheritedSelectors.
Smalltalk monitor: false.
ObjectMemory quit!"
"

"Metaclass allInstancesDo: [ :inst | '------------' print.
    	    	    	    	    inst print.
    	    	    	    	    inst printNewSelectors.
				    '' print ] !"

"| selectorSet newSelectors |
selectorSet := Set new.
Object withAllSubclasses do:
    [ :subclass | newSelectors := subclass selectors.
    	    	  '-----------------' print.
    	    	  subclass print.
		  newSelectors printSorted.
		  '' print.
		  selectorSet addAll: newSelectors ].
'****************' print.
'The set of selectors is...' print.
selectorSet size print.
selectorSet do: [ :elt | elt print ]
!"

'LIVE' printNl!

(Object withAllSubclasses asSortedCollection:
    [ :a :b | (a name isNil or: [ b name isNil ])
    	    	ifTrue: [ true ]
		ifFalse: [ a name <= b name ] ])
    do:
	[ :subclass | 
    	    subclass class ~~ Metaclass
    	    	ifTrue: [ '------------------------------------------' printNl.
		    	  subclass printNl.
    		    	  'inherited selectors' printNl.
    			  subclass printInheritedSelectors.
			  '' printNl ]
    ]!


ObjectMemory quit!


"


"**********************************************************************"

('foo' match: 'foo') printNl.
('foo' match: 'FoO') printNl.
('#oo' match: 'Foo') printNl.
('###' match: 'que') printNl.
'should be false ' print.       ('###' match: 'quem') printNl.
'should be false ' print.       ('###' match: 'bo') printNl.
'should be true  ' print.	('* string' match: 'any string') printNl.
'should be true  ' print.	('*.st' match: 'filename.st') printNl.
'should be true  ' print.	('foo.*' match: 'foo.bar') printNl.
'should be true  ' print.	('foo.*' match: 'foo.') printNl.
'should be true  ' print.	('*' match: 'foo.') printNl.
'should be true  ' print.	('*' match: '') printNl.
'should be true  ' print.	('***' match: '') printNl.
'should be true  ' print.	('*.st' match: '.st') printNl.
'should be true  ' print.	('*#*' match: '.st') printNl.
'should be true  ' print.	('*#*' match: '.s') printNl.
'should be true  ' print.	('*#*' match: 's') printNl.
'should be false ' print.	('*.st' match: '.s') printNl.
'should be false ' print.	('*#*' match: '') printNl!

ObjectMemory quit!

| j |
    j := 0.
    1 to: 1000 do:
    	[ :i | j := j + i ]!

ObjectMemory quit!

300 timesRepeat:
    [ String new: 20000 ].
'Foo ' printNl!
    

"ObjectMemory quit!"

!Object methodsFor: 'testing'!

quem
    ^1 + 2
! !

!Symbol methodsFor: 'testing'!
quem
    ^1 + 2
! !

((Object compiledMethodAt: #quem) = (Object compiledMethodAt: #quem)) printNl."


(LinkedList compiledMethodAt: #addLast:) inspect.
(CompiledMethod compiledMethodAt: #inspect) inspect.
(SmallInteger compiledMethodAt: #+) inspect.

(Stream compiledMethodAt: #next) methodSourceString printNl!
(LinkedList compiledMethodAt: #addLast:) methodSourceString printNl!

Smalltalk at: #quem put: (['foo' printNl. Processor yield ] newProcess)!
Smalltalk at: #proc2 put: (['process2' printNl. Processor yield. 
 'Hi again from proc 2' printNl. Processor yield ] newProcess)!
['process3' printNl. Processor yield ] fork!

quem resume.
proc2 resume!

'Yielding...' printNl.
Processor yield!

"proc2 terminate."
'Back to main' printNl.
Processor yield.

'Back to main from second yield' printNl.

Smalltalk at: #rambo
	  put: ([ :arg1 :arg2 | arg2 printNl". Processor yield" ]
	    	    newProcessWith: #('foo on you' 'and your mother'))!

rambo resume!
Processor yield!


ObjectMemory quit!

!ClassDescription methodsFor: 'debug'!

printClass
    | instVarNames instVars instVal |
    instanceVariables printNl.
    instVarNames := self instanceVariableString.
    instVars := (TokenStream on: instVarNames) contents.
    self printNl.
    1 to: instVars size do:
    	[ :i | '  ' print.
	       (instVars at: i) print.
	       ': ' print.
	       instVal := self instVarAt: i.
	       (instVal isKindOf: Dictionary)
    	    	   ifTrue: [ instVal printNl "'a ' print.
		    	     instVal class print.
		    	     ' with ' print.
		    	     instVal size print.
			     ' elements' printNl" ]
		   ifFalse: [ instVal printNl ] ]
! !

!Metaclass class methodsFor: 'basic'!

!

!Metaclass  methodsFor: 'basic'!

!

| newMeta |
newMeta := Metaclass subclassOf: Object class.
(newMeta class whichClassIncludesSelector: #new) printNl.
newMeta name: 'Rambo'
	environment: Smalltalk
    	subclassOf: Object
	instanceVariableNames: 'john paul  george  
ringo '
	variable: false
    	words: true
	pointers: true
    	classVariableNames: 'charlie davey'
	poolDictionaries: ''
    	category: ''
    	comment: 'no comment'

". newMeta print"!

Collection inspect!
Rambo inspect!
Rambo new inspect!

"Smalltalk system: 'mail jb'!
Smalltalk system: 'ls -lt  *.st'!"

"12500000000000000000000000000000000.0 print.

0.0625 print.
0.125 print.
0.25 print.
0.5 print.
0.12345678901234 print.

0.0 print.
1.0 print.
2.0 print.
3345678912345678.0 print!"

"Object
	defineCFunc: 'marli'
	withSelectorArgs: 'doMarli: anInteger'
	returning: #void
	args: #(#int).
nil doMarli: 3!"



"
| l |
    l := LinkedList new.
    l add: (Link new).
    l add: (Link new).
    l add: (Link new).
    l store
!"

"3.5 print. ' ' print!
3.5e5 print. ' ' print!"

"!Object methodsFor: 'test'!"

"testComp
    Object compile: (FileStream open: 'test.st' mode: 'r')"
"    Object compile: 'rambo [ ''Hi there'' print' ]"
"! !"

"nil testComp.
nil rambo!
"

| d |
Smalltalk monitor: true.
d := Date new.
10000 to: 10050 do:
    [ :i | d setDays: i.
    	   d storeString.
    	   "Character nl print" ]
. Smalltalk monitor: false
!

| s |
"Smalltalk monitor: true."
    s := Bag new.
    s add: #quem.
    s add: #zoneball.
    s add: #quem.
    s add: #juma withOccurrences: 20.
    s print.
    s store.
"    s add: #quem.
    s add: #juma."
"    s add: 12345.
    'after adding ' print."
"    s add: 'wont you please break that record' ."
"    s add: $c."
    s printOn: stdout.
    stdout nextPut: Character nl.
    s storeOn: stdout
". Smalltalk monitor: false"
!
"| f |
    f := FileStream open: 'foo.test' mode: 'w'.
    f nextPutAll: 'this is a test of your mother'.
    f nextPut: Character nl.
    f close
!

| f |
    f := FileStream open: 'foo.test' mode: 'r'.
    [ f atEnd ] whileFalse:
    	[ f next print ].
    f position: 0.
    [ f atEnd ] whileFalse:
    	[ f next print ].
    f close
!
"

!Set methodsFor: 'testing'!

printSet
    1 to: self basicSize do: [ :i | 'at ' print.
    	    	    	    	    i print.
				    (self basicAt: i) print. ]
!

findNilBefore: index
    "Finds the first nil element before index and returns the index of that
     nil.  If there is no nil element, index is returned."
    | size count i |
    count := size := self basicSize.
    i := index.
    [ count > 0 ]
    	whileTrue:
	    [ i := i - 2 \\ size + 1. "step backward w/wrap through elements"
    	      (self basicAt: i) isNil ifTrue: [ ^i ].
	      count := count - 1 ].
    ^index + 1
! !

ObjectMemory quit!

!Collection methodsFor: 'test'!

printSorted
    self asSortedCollection do:
    	[ :element | element print ]
! !

Smalltalk at: #BasicClassSelectors put: Class allSelectors!


!Behavior methodsFor: 'test'!

printInheritedSelectors
    | sels |
    sels := self allSelectors.
    sels removeAll: self selectors.
    sels printSorted
!

printNewSelectors
    | sels |
    sels := self allSelectors.
    sels removeAll: BasicClassSelectors.
    sels printSorted

! !

"Smalltalk monitor: true.
Class printInheritedSelectors.
Smalltalk monitor: false.
ObjectMemory quit!"

"Metaclass allInstancesDo: [ :inst | '------------' print.
    	    	    	    	    inst print.
    	    	    	    	    inst printNewSelectors.
				    '' print ] !"

| selectorSet newSelectors |
selectorSet := Set new.
Object withAllSubclasses do:
    [ :subclass | newSelectors := subclass selectors.
    	    	  '-----------------' print.
    	    	  subclass print.
		  newSelectors printSorted.
		  '' print.
		  selectorSet addAll: newSelectors ].
'****************' print.
'The set of selectors is...' print.
selectorSet size print.
selectorSet do: [ :elt | elt print ]
!

ObjectMemory quit!


(Object withAllSubclasses "asSortedCollection:
    [ :a :b | (a name isNil or: [ b name isNil ])
    	    	ifTrue: [ true ]
		ifFalse: [ a name <= b name ] ]")
    do:
	[ :subclass | 
    	    subclass class ~~ Metaclass
    	    	ifTrue: [ '------------------------------------------' print.
		    	  subclass print.
    		    	  'inherited selectors' print.
    			  subclass printInheritedSelectors.
			  '' print ]
    ]!
"
!Object methodsFor: 'test'!

printElements
    self do: [ :element | element print ]
!

"counter | i total |
    total := i := 0.
    [i <= self] whileTrue:
	[ total := total + i.
	  i := i + 1 ].
    ^total
!

timer | i |
    i := 0.
    [i < self] whileTrue: [ i := i + 1 ]
"

count2
    | sum |
    sum := 0.
    1 to: self do: [ :i | sum := sum + i ].
    ^sum
!

myTest
    ^12 factorial

! !

!Integer methodsFor: 'test'!

factorial
    self > 0 ifTrue: [ self * (self - 1) factorial ]
    	     ifFalse: [ ^self error: 'factorial of a small number' ]
! !

^Symbol allInstances size!

ObjectMemory quit!

"^Date yearAsDays: 1904!



1850 to: 2050 do:
    [ :year | year print.
    	      (Date leapYear: year) print ]!"

| s |
    s := WriteStream on: (String new: 0).
    s nextPutAll: 'name'.
    s tab.
    s nextPutAll: 'city'.
    s reset.
    s nextPutAll: 'foo'.
    s setToEnd.
    s nl.
    s nextPutAll: 'quem?'.
    s workingSize print.
    ^s contents
!




| s str|
    str := WriteStream on: (String new: 5).
    s := #(#foo #bar #baz #quem #juma #zoneball).
    s do: [ :sym | str nextPutAll: sym , ' ' ].
    ^str contents
"    s := s inject: '' into: [ :str :atom | str , atom , ' ' ].
    s size print.
    s grow.
    s size print.
    s print"
!

| t |
    t := #(#foo #bar #baz).
    t := t , #(#quem #juma).
    t do: [ :element | element print ]!


"
Smalltalk at: #children put: SortedCollection new!


^children add: #Joe!
^children add: #Bill!
^children add: #Alice!
^children printElements!
^children add: #Sam!
^(children sortBlock: [ :a :b | a > b ]) printElements!
^children add: #Henrietta!
^children printElements!
"
| t |
    t := SortedCollection new.
    t add: 'foo'.
    t add: 'bar'.
    t add: 'dinner'.
    t add: 'in'.
    t add: 'the'.
    t add: 'diner'.
    t add: 'nothing'.
    t add: 'could'.
    t add: 'be'.
    t add: 'finer'.
    "1 to: t size do: [ :i | i print. (t at: i ) print ]."
    t sortBlock: [ :a :b | a > b ].
    1 to: t size do: [ :i | i print. (t at: i ) print ].
!



600 to: 1000 do:
    [ :i | i print.
    	   i asObject print ]!


^(Bag with: #foo with: #foo ) occurrencesOf: #foo!


"
Smalltalk at: #Test put: Dictionary new.
Smalltalk at: #X put: 0!
X := Bag new!
^X occurrencesOf: 3!
^X add: 3!

Test at: #jeff put: 1.
Test at: #steve put: 5.
Test at: #jiz put: 99!
^Test at: #jeff!
^Test at: #steve!
^Test at: #jiz!


X := Test collect: [ :elt | elt * 2 ]!
^X occurrencesOf: 1!
^X occurrencesOf: 2!
^X occurrencesOf: 5!
^X occurrencesOf: 10!
^X occurrencesOf: 99!
^X occurrencesOf: 99*2!
^X size!
"
"
^Test at: #blockA put: [ 'this is a test' ]!
^Test at: #blockB put: [ 'hello from block b' ]!
^Test at: #juma put: 'hello jeff! !!'!
^Test size!
^Test at: #juma!

^(Test at: #blockB) value!
^(Test at: #blockA) value!

^Test removeKey: #juma!
^Test size!
^Test removeKey: #juma!
"

"^Test := Bag new!

^Test add: #quem!
^Test size!
^Test basicSize!
"

"
^Test := Set new!

^'test'!
^Test basicSize!

^Test findObjectIndex: #foo!
^Test species!

^Test add: #quem!
^Test add: #juma!

^Test size!
^Test grow!
^Test add: #juma2!
^Test add: #juma3!

^Test size!
^Test basicSize!

^Test findObjectIndex: #juma2!
^Test remove: #juma2!
^Test findObjectIndex: #juma2!
^Test basicAt: (Test findObjectIndex: #juma2)!
^Test size!
^Test occurrencesOf: #juma2!
^Test occurrencesOf: #juma3!
^Test remove: #juma2!"

"^3 * 4.0!

^Float pi!

^'QuemonYour:Mother:' asSymbol!

^3 zoneball!

^#FoobarOnYouBar asUppercase!

[]!

^[] value!

^3 count2!
^4 count2!"

"
!Object methodsFor: 'test'!

dictTest
    | d |
    d := Dictionary new.
    d at: #foo put: #bar.
    d at: #quem put: #juma.
    d at: #barf put: 'your mama'.
    ^d at self     
! !"



"Smalltalk at: #poolDict1 put: Dictionary new!
Smalltalk at: #poolDict2 put: Dictionary new!

poolDict1 at: #pd1foo put: 'foo'!
poolDict1 at: #pd1bar put: #bar!

poolDict2 at: #pd2baz put: 'bazola'!
poolDict2 at: #pd2barn put: #fred! 


Object subclass: #Rambo
	instanceVariableNames: 'foo bar'
	classVariableNames: 'guinea pigs'
	poolDictionaries: 'poolDict1'
	category: ''!

!Rambo methodsFor: 'test'!

xxx
   pd1foo := 3.
   ^pd1bar testMessage: pd2barn + pd2baz
!

ramboTest
    foo := 3.
    bar := 7.
    ^foo + bar
!

initPigs: guineaArg and: pigsArg
    guinea := guineaArg.
    pigs := pigsArg
!

foof
    ^foo
!

barf
    ^bar
!

returnGuinea
    ^guinea
!

returnPigs
    ^pigs

! !

Rambo subclass: #Rocky
	instanceVariableNames: 'quem juma'
	classVariableNames: ''
	poolDictionaries: 'poolDict2'
	category: ''!

!Rocky methodsFor: 'test'!

xxx
   pd1foo := 3.
   ^pd1bar testMessage: pd2barn + pd2baz
!

ramboTest
    foo := 12.
    bar := 3.
    ^foo + bar
!


quem: arg
    quem := arg
!

quem
    ^quem
!

juma: arg
   juma := arg
!

juma
    ^juma

! !
"

"Smalltalk at: #testVar put: Rambo new!"

"^#barf dictTest!
^#foo dictTest!
^#quem dictTest!"



"^2 arrayTest!"



"^nil atest2!"

"   ^$C = ('FUBAR' at: 3) !"

"^1000 counter !"

"^16rA + 16rA !

^$C !

^#foo:bar:baz: !
^'this is a test string
I wonder how this will print' !"

"100000 timer!"
	


"^3 < 4 ifTrue: [^#foobar] !"

"
!Boolean methodsFor: 'test'!
quem: bar juma: baz
    bar := #foon:barn:.
    baz := 3.
!

marli
    true when: [3 < (Smalltalk at: #foo)] do: #quem:bar:.
    Smalltalk at: #foo put: 3

! !

!String methodsFor: 'your mother'!
xxx: arg
    self < arg ifTrue: [^false].
    (self = arg and: [arg + 1 > 3]) ifTrue: [^#foo]
! !

"

"playing with dates!Date methodsFor: 'rambo'!

computeDateParts: aBlock
    | trialYearInteger yearInteger tempDays monthIndex daysInMonth offset |
    trialYearInteger := (days // 365).
    offset := (trialYearInteger // 4) - (trialYearInteger // 100) + (trialYearInteger // 400).
""yearInteger print. 
' Days: ' print. days print. 
' year ' print. (yearInteger * 365) print.
' offset ' print. offset printNl.""
    yearInteger := trialYearInteger.
    tempDays := days - (yearInteger * 365).
'>>> Days: ' print. tempDays print. 
' offset ' print. offset printNl.

    tempDays < offset
""    (days - offset) < (yearInteger * 365)""
    	ifTrue: [ yearInteger := yearInteger - 1 ]
	ifFalse: [ tempDays := tempDays - offset ].
""     
    yearInteger := (days - offset) // 365.
    yearInteger = trialYearInteger
    	ifTrue: [ tempDays := tempDays - offset ].""
    yearInteger := yearInteger + 1901.
    monthIndex := 1.
    [ monthIndex < 12
    	and: [ daysInMonth := Date daysInMonthIndex: monthIndex
	    	    	    	  forYear: yearInteger.
    	       tempDays >= daysInMonth ] ] whileTrue:
    	[ monthIndex := monthIndex + 1.
	  tempDays := tempDays - daysInMonth ].
    ^aBlock value: yearInteger value: monthIndex value: tempDays + 1
! !
"