-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeCoverageDemo.pck.st
1384 lines (972 loc) · 46.8 KB
/
CodeCoverageDemo.pck.st
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
'From Cuis 6.0 [latest update: #5510] on 11 November 2022 at 7:53:13 am'!
'Description '!
!provides: 'CodeCoverageDemo' 1 10!
SystemOrganization addCategory: 'CodeCoverageDemo'!
!classDefinition: #CodeEditorSlide category: 'CodeCoverageDemo'!
LayoutMorph subclass: #CodeEditorSlide
instanceVariableNames: 'codeEditor compiledMethod reportBuilderFactory selector receiver toolbar2 contentPane testCases2 testCasesList argumentInputs2 argumentsBuilder'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'CodeEditorSlide class' category: 'CodeCoverageDemo'!
CodeEditorSlide class
instanceVariableNames: ''!
!classDefinition: #PresentationWindow category: 'CodeCoverageDemo'!
SystemWindow subclass: #PresentationWindow
instanceVariableNames: 'slides currentSlide originalTitle targetSlide'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'PresentationWindow class' category: 'CodeCoverageDemo'!
PresentationWindow class
instanceVariableNames: ''!
!classDefinition: #ImageSlide category: 'CodeCoverageDemo'!
BoxedMorph subclass: #ImageSlide
instanceVariableNames: 'image toolbar'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'ImageSlide class' category: 'CodeCoverageDemo'!
ImageSlide class
instanceVariableNames: ''!
!classDefinition: #BasicDecisionConditionCoverageReportBuilder category: 'CodeCoverageDemo'!
DecisionConditionCoverageReportBuilder subclass: #BasicDecisionConditionCoverageReportBuilder
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'BasicDecisionConditionCoverageReportBuilder class' category: 'CodeCoverageDemo'!
BasicDecisionConditionCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #ConditionCoverageReportBuilder category: 'CodeCoverageDemo'!
DecisionConditionCoverageReportBuilder subclass: #ConditionCoverageReportBuilder
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'ConditionCoverageReportBuilder class' category: 'CodeCoverageDemo'!
ConditionCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #DecisionCoverageReportBuilder category: 'CodeCoverageDemo'!
CompiledMethodCoverageTracker subclass: #DecisionCoverageReportBuilder
instanceVariableNames: 'coveredNonBooleanSourceRanges compiledMethod analyzedSourceRanges booleanValuesByDeclaration usagesByDeclaration compiledMethodWasExecuted sourceRanges2 decisionReceverRanges decisionSelectors'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'DecisionCoverageReportBuilder class' category: 'CodeCoverageDemo'!
DecisionCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #LineCoverageReportBuilder category: 'CodeCoverageDemo'!
CompiledMethodCoverageTracker subclass: #LineCoverageReportBuilder
instanceVariableNames: 'compiledMethod analyzedSourceRanges compiledMethodWasExecuted coveredSourceRanges'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'LineCoverageReportBuilder class' category: 'CodeCoverageDemo'!
LineCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #MethodCoverageReportBuilder category: 'CodeCoverageDemo'!
CompiledMethodCoverageTracker subclass: #MethodCoverageReportBuilder
instanceVariableNames: 'compiledMethod analyzedSourceRanges compiledMethodWasExecuted'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'MethodCoverageReportBuilder class' category: 'CodeCoverageDemo'!
MethodCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #StatementCoverageReportBuilder category: 'CodeCoverageDemo'!
CompiledMethodCoverageTracker subclass: #StatementCoverageReportBuilder
instanceVariableNames: 'compiledMethod analyzedSourceRanges compiledMethodWasExecuted coveredSourceRanges'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'StatementCoverageReportBuilder class' category: 'CodeCoverageDemo'!
StatementCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageArgumentsBuilder category: 'CodeCoverageDemo'!
Object subclass: #CodeCoverageArgumentsBuilder
instanceVariableNames: 'booleanArgument anotherBooleanArgument'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'CodeCoverageArgumentsBuilder class' category: 'CodeCoverageDemo'!
CodeCoverageArgumentsBuilder class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageExamples category: 'CodeCoverageDemo'!
Object subclass: #CodeCoverageExamples
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'CodeCoverageExamples class' category: 'CodeCoverageDemo'!
CodeCoverageExamples class
instanceVariableNames: ''!
!classDefinition: #ConditionCoverageArgumentsBuilder category: 'CodeCoverageDemo'!
Object subclass: #ConditionCoverageArgumentsBuilder
instanceVariableNames: 'booleanArgument anotherBooleanArgument'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'ConditionCoverageArgumentsBuilder class' category: 'CodeCoverageDemo'!
ConditionCoverageArgumentsBuilder class
instanceVariableNames: ''!
!classDefinition: #DecisionConditionCoverageArgumentsBuilder category: 'CodeCoverageDemo'!
Object subclass: #DecisionConditionCoverageArgumentsBuilder
instanceVariableNames: 'booleanArgument anotherBooleanArgument yetAnotherBooleanArgument'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'DecisionConditionCoverageArgumentsBuilder class' category: 'CodeCoverageDemo'!
DecisionConditionCoverageArgumentsBuilder class
instanceVariableNames: ''!
!classDefinition: #DecisionCoverageArgumentsBuilder category: 'CodeCoverageDemo'!
Object subclass: #DecisionCoverageArgumentsBuilder
instanceVariableNames: 'booleanArgument'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'DecisionCoverageArgumentsBuilder class' category: 'CodeCoverageDemo'!
DecisionCoverageArgumentsBuilder class
instanceVariableNames: ''!
!classDefinition: #Smalltalks2022Presentation category: 'CodeCoverageDemo'!
Object subclass: #Smalltalks2022Presentation
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverageDemo'!
!classDefinition: 'Smalltalks2022Presentation class' category: 'CodeCoverageDemo'!
Smalltalks2022Presentation class
instanceVariableNames: ''!
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:14:12'!
addTestCase
testCases2 add: argumentsBuilder buildArguments.
self changed: #testCases.
testCasesList redrawNeeded
! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/9/2022 02:23:54'!
arguments
^ {}! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/11/2022 06:33:04'!
buildArgumentInputs
| argumentInputs arguments rightPane buttonsRow |
arguments := (receiver class >> selector) methodNode arguments.
arguments ifEmpty: [
toolbar2 addMorph: ((PluggableButtonMorph model: self action: #runMethodWithoutArguments label: 'Run') color: Color veryVeryLightGray);
addMorph: ((PluggableButtonMorph model: self action: #clearTestCases label: 'Clear') color: Color veryVeryLightGray).
^ self ].
rightPane := LayoutMorph newColumn color: Color veryLightGray.
argumentInputs := LayoutMorph newColumn color: Color veryLightGray.
arguments do: [ :argument |
argumentInputs addMorph: (self buildInputFor: argument) fixedHeight: 20 ].
buttonsRow := LayoutMorph newRow axisEdgeWeight: 0.5; separation: 5@0; color: Color veryLightGray.
buttonsRow
addMorph: ((PluggableButtonMorph model: self action: #addTestCase label: 'Add') color: Color veryVeryLightGray);
addMorph: ((PluggableButtonMorph model: self action: #clearTestCases label: 'Clear') color: Color veryVeryLightGray);
addMorph: ((PluggableButtonMorph model: self action: #runTestCases label: 'Run') color: Color veryVeryLightGray).
testCasesList := (PluggableListMorph model: self listGetter: #testCases indexGetter: #testCaseIndex indexSetter: #testCaseIndex:) color: Color veryLightGray..
rightPane
addMorph: argumentInputs fixedHeight: (arguments size * 20);
addMorph: buttonsRow fixedHeight: 20;
addMorphUseAll: testCasesList .
contentPane addMorph: rightPane fixedWidth: 400.! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:14:19'!
buildInputFor: argument
| argumentRow selectorName |
argumentRow := LayoutMorph newRow separation: 5@5; color: Color veryLightGray..
argumentRow addMorph: (LabelMorph contents: argument key).
selectorName := (argument key,'Argument') asSymbol.
argumentRow addMorphUseAll: ((TextModelMorph textProvider: argumentsBuilder textGetter: selectorName textSetter: (selectorName, ':') asSymbol) acceptOnAny: true).
^ argumentRow! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:10:38'!
clearTestCases
testCases2 removeAll.
self buildCodeEditorWith: Browser new.
self changed: #testCases! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:05:44'!
foo
| analyzer browser |
analyzer := CodeCoverageAnalyzer
toAnalyzeAll: { receiver class >> selector }
creatingReportBuildersWith: reportBuilderFactory.
analyzer value: [
self testCases do: [ :arguments |
receiver perform: selector withArguments: arguments ] ].
browser := CodeCoverageAnalyzerBrowser displayingCodeCoverageResultsFrom: analyzer report.
self buildCodeEditorWith: browser! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/9/2022 02:40:49'!
nextSlide
self owner owner nextSlide! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 16:59:34'!
previousSlide
self owningWindow previousSlide! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:07:14'!
runMethodWithoutArguments
self runTestCase: {{}}! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 01:19:24'!
runTestCase: arguments
| analyzer browser |
analyzer := CodeCoverageAnalyzer
toAnalyzeAll: { receiver class >> selector }
creatingReportBuildersWith: reportBuilderFactory.
analyzer value: [
arguments do: [ :args |
receiver perform: selector withArguments: args ] ].
browser := CodeCoverageAnalyzerBrowser displayingCodeCoverageResultsFrom: analyzer report.
self buildCodeEditorWith: browser! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:00:43'!
runTestCases
self runTestCase: testCases2 ! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 01:14:09'!
testCaseIndex
^ 0! !
!CodeEditorSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 01:15:38'!
testCases
^ testCases2 collect: [:t | t asString ]! !
!CodeEditorSlide methodsFor: 'initialization' stamp: 'NPM 11/10/2022 15:46:45'!
buildCodeEditorWith: aBrowser
| newCodeEditor |
self owningWindow ifNotNil: [ :window | window model: aBrowser ].
aBrowser setSelectedSystemCategory:receiver class category.
aBrowser selectClass: receiver class.
aBrowser selectedMessageName: selector.
newCodeEditor := TextModelMorph
textProvider: aBrowser
textGetter: #acceptedContents
textSetter: #contents:notifying:
selectionGetter: #contentsSelection.
newCodeEditor layoutSpec: LayoutSpec useAll.
codeEditor
ifNotNil: [contentPane replaceSubmorph: codeEditor by: newCodeEditor ]
ifNil: [ contentPane addMorphUseAll: newCodeEditor ].
codeEditor := newCodeEditor.! !
!CodeEditorSlide methodsFor: 'initialization' stamp: 'NPM 11/10/2022 16:48:50'!
buildContentPane
contentPane := LayoutMorph newRow.
self addMorphUseAll: contentPane.
self buildCodeEditorWith: Browser new.
self buildArgumentInputs! !
!CodeEditorSlide methodsFor: 'initialization' stamp: 'NPM 11/10/2022 16:56:26'!
buildToolbar
toolbar2 := LayoutMorph newRow doAdoptWidgetsColor;
color: Color veryLightGray;
separation: 10.
toolbar2 addMorph: ((PluggableButtonMorph model: self action: #previousSlide label: '<') color: Color veryVeryLightGray).
toolbar2 addMorph: ((PluggableButtonMorph model: self action: #nextSlide label: '>') color: Color veryVeryLightGray).
^ self addMorph: toolbar2 fixedHeight: 10.! !
!CodeEditorSlide methodsFor: 'initialization' stamp: 'NPM 11/10/2022 17:23:48'!
initializeToEdit: aCompiledMethod selector: aSelector creatingReportBuildersWith: aReportBuilderFactory buildingArgumentsWith: anArgumentsBuilder
receiver := aCompiledMethod.
selector := aSelector.
reportBuilderFactory := aReportBuilderFactory.
testCases2 := OrderedCollection new.
argumentsBuilder := anArgumentsBuilder.
self buildToolbar.
self buildContentPane.! !
!CodeEditorSlide class methodsFor: 'as yet unclassified' stamp: 'NPM 11/8/2022 17:51:16'!
new
^ self
newColumn! !
!CodeEditorSlide class methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:18:19'!
on: aCompiledMethod selector: aSelector creatingReportBuildersWith: aReportBuilderFactory
^ self
new
initializeToEdit: aCompiledMethod
selector: aSelector
creatingReportBuildersWith: aReportBuilderFactory
buildingArgumentsWith: nil! !
!CodeEditorSlide class methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:17:48'!
on: aCompiledMethod selector: aSelector creatingReportBuildersWith: aReportBuilderFactory buildingArgumentsWith: anArgumentsBuilder
^ self
new
initializeToEdit: aCompiledMethod
selector: aSelector
creatingReportBuildersWith: aReportBuilderFactory buildingArgumentsWith: anArgumentsBuilder! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 19:06:05'!
addSlide: aSlide
slides ifEmpty: [
aSlide morphExtent: self morphExtent.
layoutMorph addMorphUseAll: aSlide.
currentSlide := aSlide ].
slides add: aSlide.
! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/11/2022 07:00:49'!
fullScreen
"Zoom Window to Full World size with possible DeskMargins"
| left right possibleBounds |
(self hasProperty: #originalBounds)
ifFalse: [ "Expand"
self setProperty: #originalBounds toValue: self displayBounds.
left := right := 0.
possibleBounds := (RealEstateAgent maximumUsableAreaInWorld: self world)
insetBy: (left @ 0 corner: right @ 0).
"possibleBounds := possibleBounds insetBy: Theme current fullScreenDeskMargin"
]
ifTrue: [ "Contract"
possibleBounds := self valueOfProperty: #originalBounds.
self removeProperty: #originalBounds.
].
self morphPosition: possibleBounds topLeft extent: possibleBounds extent! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/9/2022 02:52:50'!
initialize
super initialize.
slides := OrderedCollection new.
originalTitle := 'Code Coverage Examples'.! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 18:25:17'!
nextSlide
| currentIndex |
slides last = currentSlide ifTrue: [ ^ self ].
currentIndex := slides indexOf: currentSlide.
targetSlide := slides at: (currentIndex +1).
layoutMorph removeMorph: currentSlide.
currentSlide := (slides at: currentIndex + 1).
layoutMorph addMorphUseAll: currentSlide.
labelString := originalTitle.
super model: nil.
self redrawNeeded
! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/9/2022 02:53:43'!
openInWorld
labelString := originalTitle.
super openInWorld! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/9/2022 02:55:02'!
previousSlide
| currentIndex |
slides first = currentSlide ifTrue: [ ^ self ].
currentIndex := slides indexOf: currentSlide.
layoutMorph removeMorph: currentSlide.
currentSlide := (slides at: currentIndex - 1).
layoutMorph addMorphUseAll: currentSlide.
labelString := originalTitle.
super model: nil.
self redrawNeeded! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 18:26:04'!
stepAt: millisecondSinceLast
! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/8/2022 19:12:47'!
submorphToFocusKeyboard
^ self! !
!PresentationWindow methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 18:25:54'!
wantsSteps
^ true! !
!ImageSlide methodsFor: 'initialization' stamp: 'NPM 11/11/2022 06:49:00'!
initializeForm: aForm
self buildToolbar .
image := (ImageMorph new image: (aForm )).
self addMorph: image.
! !
!ImageSlide methodsFor: 'initialization' stamp: 'NPM 11/11/2022 06:53:29'!
layoutSubmorphs
| aForm newImage scale xScale yScale |
toolbar
morphPosition: 0@0;
morphExtent: (self morphWidth @ 20).
aForm := image form .
xScale := self morphExtent x / aForm width.
yScale:= (self morphExtent y - 20) / aForm height.
scale := xScale max: yScale..
newImage := ImageMorph new image: (aForm magnifyBy: scale).
self replaceSubmorph: image by: newImage.
image := newImage.
newImage morphPosition: 0@(toolbar morphHeight).
self layoutNeeded: false! !
!ImageSlide methodsFor: 'initialization' stamp: 'NPM 11/11/2022 06:47:34'!
layoutSubmorphs2
| aForm newImage scale xScale yScale |
aForm := image form .
xScale := self morphExtent x / aForm width.
yScale:= self morphExtent y / aForm height.
scale := xScale max: yScale..
newImage := ImageMorph new image: (aForm magnifyBy: scale).
self replaceSubmorph: image by: newImage.
image := newImage.
self layoutNeeded: false! !
!ImageSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/11/2022 06:49:28'!
buildToolbar
toolbar := LayoutMorph newRow doAdoptWidgetsColor;
color: Color veryLightGray;
separation: 10.
toolbar addMorph: ((PluggableButtonMorph model: self action: #previousSlide label: '<') color: Color veryVeryLightGray).
toolbar addMorph: ((PluggableButtonMorph model: self action: #nextSlide label: '>') color: Color veryVeryLightGray).
^ self addMorph: toolbar! !
!ImageSlide methodsFor: 'as yet unclassified' stamp: 'NPM 11/11/2022 06:52:47'!
clipsSubmorphs
^ true! !
!ImageSlide class methodsFor: 'instance creation' stamp: 'NPM 11/11/2022 06:48:52'!
form: aForm
^self new initializeForm: aForm ! !
!BasicDecisionConditionCoverageReportBuilder methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 18:02:31'!
registerBoolean: aBoolean usedAt: usageSourceRange declaredAt: declarationSourceRange
self registerBoolean: aBoolean declaredAt: usageSourceRange.
self coverAsNonBoolean: declarationSourceRange ! !
!ConditionCoverageReportBuilder methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:44:16'!
coverAll: sourceRanges fromSending: aSelector to: aReceiver
self coverAll: sourceRanges! !
!ConditionCoverageReportBuilder methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 17:44:24'!
coverAll: sourceRanges fromSending: aSelector to: anObject withResult: result
self coverAll: sourceRanges by: result! !
!ConditionCoverageReportBuilder methodsFor: 'as yet unclassified' stamp: 'NPM 11/10/2022 18:01:19'!
registerBoolean: aBoolean usedAt: usageSourceRange declaredAt: declarationSourceRange
self registerBoolean: aBoolean declaredAt: usageSourceRange.
self coverAsNonBoolean: declarationSourceRange ! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
collectWithUsages: sourceRanges
^ sourceRanges
inject: Set new
into: [ :result :sourceRange |
result
add: sourceRange;
addAll: (self usagesOf: sourceRange);
yourself ]! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
coveredSourceRanges
^ self fullyCoveredSourceRanges, self partiallyCoveredBooleanRanges! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
fulllyCoveredNonBooleanSourceRanges
^ self collectWithUsages: coveredNonBooleanSourceRanges! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
fullyCoveredBooleanSourceRanges
"A fully-covered boolean source range is one that referenced both true and false."
^ self selectBooleanSourceRanges: [ :coveredValues | coveredValues size = 2 ]! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
fullyCoveredSourceRanges
^ self fulllyCoveredNonBooleanSourceRanges, self fullyCoveredBooleanSourceRanges! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
partiallyCoveredBooleanRanges
"A partially-covered boolean source range is one that referenced either true or false."
^ self selectBooleanSourceRanges: [ :coveredValues | coveredValues size = 1 ]! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
selectBooleanSourceRanges: aCondition
"Select the boolean source range declarations passing the covered boolean values referenced by them to aCondition.
Return both the declarations that satisfies aCondition and their usages."
| selectedDeclarations |
selectedDeclarations := booleanValuesByDeclaration associations
select: [ :sourceRangeAndCoveredValues | aCondition value: sourceRangeAndCoveredValues value ]
thenCollect: [ :sourceRangeAndCoveredValues | sourceRangeAndCoveredValues key ].
^ self collectWithUsages: selectedDeclarations! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
uncoveredSourceRanges
^ analyzedSourceRanges difference: self coveredSourceRanges! !
!DecisionCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 03:31:01'!
usagesOf: aDeclaration
^ usagesByDeclaration
at: aDeclaration
ifAbsent: [ Set new ]! !
!DecisionCoverageReportBuilder methodsFor: 'evaluating' stamp: 'NPM 11/7/2022 03:31:01'!
value
^ CodeCoverageReport
for: compiledMethod
executed: compiledMethodWasExecuted
with: self consolidateCoverageResults
messages: self messages.! !
!DecisionCoverageReportBuilder methodsFor: 'initialization' stamp: 'NPM 11/7/2022 03:31:01'!
initializeFor: aCompiledMethod with: aCollecitonOfAnalizedSourceRanges
compiledMethod := aCompiledMethod.
analyzedSourceRanges := aCollecitonOfAnalizedSourceRanges.
coveredNonBooleanSourceRanges := Set new.
booleanValuesByDeclaration := Dictionary new.
usagesByDeclaration := Dictionary new.
compiledMethodWasExecuted := false.
decisionSelectors := #(#ifTrue: #ifFalse: #ifTrue:ifFalse: #ifFalse:ifTrue:).! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/9/2022 02:34:39'!
consolidateCoverageResults
| coverageRatioBySourceRange |
coverageRatioBySourceRange := Dictionary new.
(self fullyCoveredSourceRanges)
do: [ :sourceRange | coverageRatioBySourceRange at: sourceRange put: 1 ].
self partiallyCoveredBooleanRanges
do: [ :sourceRange | coverageRatioBySourceRange at: sourceRange put: 0.5 ].
(self uncoveredSourceRanges)
do: [ :sourceRange | coverageRatioBySourceRange at: sourceRange put: 0 ].
^ coverageRatioBySourceRange! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:35:15'!
cover: aSourceRange declaredAt: declarationSourceRange by: anObject
"Register thatanObject covered aSourceRange and its declaration at declarationSourceRange."
self
coverNonBooleanUsage: aSourceRange
of: declarationSourceRange.
^ anObject! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverAll: sourceRanges
self coverAsNonBooleanAll: sourceRanges! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverAll: sourceRanges by: anObject
(anObject isKindOf: Boolean)
ifTrue: [ self registerBoolean: anObject declaredAtAll: sourceRanges ]
ifFalse: [ self coverAsNonBooleanAll: sourceRanges ].
^ anObject! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverAll: sourceRanges byLiteralOrPseudoVariable: anObject
"Register that anObject covered sourceRanges"
"Literal or pseudo-variables should not be covered as boolean because
true would always be covered 50% when it should be 100% (it is the true pseudo-variable)"
self coverAsNonBooleanAll: sourceRanges.
^ anObject! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverAll: sourceRanges fromSending: aSelector to: aReceiver
(self isDecisionSelector: aSelector )
ifTrue: [
self
coverDecisionMessageSendTo: aReceiver
atAll: sourceRanges ]
ifFalse: [
self coverAll: sourceRanges ]! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/8/2022 02:07:27'!
coverAll: sourceRanges fromSending: aSelector to: anObject withResult: result
(self isDecisionSelector: aSelector )
ifTrue: [
self
coverDecisionMessageSendTo: anObject
atAll: sourceRanges ]
ifFalse: [
self coverAsNonBooleanAll: sourceRanges ]! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:33:32'!
coverAsNonBoolean: aSourceRange
coveredNonBooleanSourceRanges add: aSourceRange.! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverAsNonBooleanAll: sourceRanges
sourceRanges do: [ :sourceRange | self coverAsNonBoolean: sourceRange ]! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverDecisionMessageSendTo: aReceiver atAll: sourceRanges
coveredNonBooleanSourceRanges
removeAllFoundIn: sourceRanges.
self
registerBoolean: aReceiver
declaredAtAll: sourceRanges ! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
coverNonBooleanUsage: usageSourceRange of: declarationSourceRange
"Consider both usageSourceRange and declarationSourceRange as covered.
This is used, for instance, when a temporary variable is assigned:
- the temporary variable in the assignment is found at usageSourceRange.
- the temporary variable declaration is found at declarationSourceRange."
self
registerUsage: usageSourceRange of: declarationSourceRange;
coverAsNonBoolean: declarationSourceRange.! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
markAsExecuted
compiledMethodWasExecuted := true.! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
messages
^ booleanValuesByDeclaration
select: [ :coveredValues | coveredValues size = 1 ]
thenCollect: [ :coveredValues |
| exercisedTestCase missingTestCase |
exercisedTestCase := coveredValues anyOne.
missingTestCase := exercisedTestCase ifTrue: [ false ] ifFalse: [ true ].
String newLineString,
'Code Coverge: missing test case: ', missingTestCase asString, '. Only exercised with ',
exercisedTestCase asString, '.' ]! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/9/2022 02:34:34'!
registerBoolean: aValue declaredAt: declarationSourceRange
"Consider declarationSourceRange as a covered boolean source range."
"If declarationSourceRange is currently considered non-boolean (e.g. it is related to non-boolean objects),
don't consider it a boolean declaration."
(coveredNonBooleanSourceRanges includes: declarationSourceRange)
ifTrue: [ ^ self coverAsNonBoolean: declarationSourceRange ].
(booleanValuesByDeclaration at: declarationSourceRange ifAbsentPut: [ Set new ])
add: aValue! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
registerBoolean: aBoolean declaredAtAll: declarationSourceRanges
"Consider declarationSourceRanges as covered boolean source ranges.
An example of a boolean having multilple declarations is a keyword message that returned the boolean value:
self foo: 1 bar: 2 baz: 3.
Assuming that #foo:bar:baz: returns a boolean, it is considered to be declared at 3 source ranges: one for each keyword in the selector."
declarationSourceRanges do: [ :declarationSourceRange |
self registerBoolean: aBoolean declaredAt: declarationSourceRange ]! !
!DecisionCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:31:01'!
registerUsage: aSourceRange of: declarationSourceRange
(usagesByDeclaration at: declarationSourceRange ifAbsentPut: [ Set new ])
add: aSourceRange! !
!DecisionCoverageReportBuilder methodsFor: 'testing' stamp: 'NPM 11/7/2022 03:31:01'!
isDecisionSelector: aSelector
^ decisionSelectors includes: aSelector! !
!DecisionCoverageReportBuilder class methodsFor: 'instance creation' stamp: 'NPM 11/7/2022 03:31:01'!
for: aCompiledMethod withSourceRanges: sourceRanges
^ self
new
initializeFor: aCompiledMethod
with: sourceRanges! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:27:35'!
compiledMethod
^ compiledMethod! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:27:35'!
consolidateCoverageResults
^ analyzedSourceRanges
inject: Dictionary new
into: [ :coverageRatioBySourceRange :aSourceRange |
coverageRatioBySourceRange
at: aSourceRange
put: (self coverageRatioFor: aSourceRange).
coverageRatioBySourceRange ]! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 02:56:52'!
cover: aSourceRange
| end range sourceCode x j |
sourceCode := compiledMethod sourceCode.
end _ sourceCode indexOf: Character newLineCharacter startingAt: aSourceRange first ifAbsent: [ sourceCode size ].
x _ sourceCode copyFrom: aSourceRange first to: end.
range _ aSourceRange first to: end.
j := analyzedSourceRanges select: [ :r | range includesAllOf: r ].
coveredSourceRanges addAll: (j)! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/7/2022 02:55:30'!
coverageRatioFor: aSourceRange
^ (coveredSourceRanges includes: aSourceRange)
ifTrue: [ 1.0 ]
ifFalse: [ 0.0 ]! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:27:35'!
messageCategory
^ compiledMethod category! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:27:35'!
methodClass
^ compiledMethod methodClass! !
!LineCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:27:35'!
systemCategory
^ compiledMethod
methodClass
category ! !
!LineCoverageReportBuilder methodsFor: 'evaluating' stamp: 'NPM 11/6/2022 12:20:02'!
value
^ CodeCoverageReport
for: compiledMethod
executed: compiledMethodWasExecuted
with: self consolidateCoverageResults messages: nil.! !
!LineCoverageReportBuilder methodsFor: 'initialization' stamp: 'NPM 11/7/2022 02:55:30'!
initializeFor: aCompiledMethod with: aCollecitonOfAnalizedSourceRanges
compiledMethod := aCompiledMethod.
analyzedSourceRanges := aCollecitonOfAnalizedSourceRanges.
compiledMethodWasExecuted := false.
coveredSourceRanges _ Set new.! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 03:43:07'!
cover: aSourceRange declaredAt: declarationSourceRange by: anObject
self cover: aSourceRange.
self cover: declarationSourceRange.
^ anObject! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:40:36'!
coverAll: sourceRanges
sourceRanges do: [ :r | self cover: r ].! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:56:29'!
coverAll: sourceRanges by: anObject
self coverAll: sourceRanges.
^ anObject! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:40:36'!
coverAll: sourceRanges byLiteralOrPseudoVariable: anObject
sourceRanges do: [ :r | self cover: r ].
^ anObject! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:57:39'!
coverAll: sourceRanges fromSending: aSelector to: aReceiver
self coverAll: sourceRanges.! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:57:18'!
coverAll: sourceRanges fromSending: aSelector to: aReceiver withResult: aResult
self coverAll: sourceRanges! !
!LineCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/3/2022 00:27:35'!
markAsExecuted
compiledMethodWasExecuted := true.! !
!LineCoverageReportBuilder class methodsFor: 'instance creation' stamp: 'NPM 11/3/2022 00:27:35'!
for: aCompiledMethod withSourceRanges: sourceRanges
^ self
new
initializeFor: aCompiledMethod
with: sourceRanges! !
!MethodCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/2/2022 23:47:58'!
compiledMethod
^ compiledMethod! !
!MethodCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/3/2022 00:17:37'!
coverageRatioFor: aSourceRange
^ compiledMethodWasExecuted
ifTrue: [ 1.0 ]
ifFalse: [ 0.0 ]! !
!MethodCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/2/2022 23:48:22'!
messageCategory
^ compiledMethod category! !
!MethodCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/2/2022 23:48:11'!
methodClass
^ compiledMethod methodClass! !
!MethodCoverageReportBuilder methodsFor: 'accessing' stamp: 'NPM 11/2/2022 23:48:37'!
systemCategory
^ compiledMethod
methodClass
category ! !
!MethodCoverageReportBuilder methodsFor: 'evaluating' stamp: 'NPM 11/7/2022 02:22:57'!
value
^ CodeCoverageReport
for: compiledMethod
executed: compiledMethodWasExecuted
with: self consolidateCoverageResults
messages: Dictionary new.! !
!MethodCoverageReportBuilder methodsFor: 'initialization' stamp: 'NPM 11/3/2022 00:13:27'!
initializeFor: aCompiledMethod with: aCollecitonOfAnalizedSourceRanges
compiledMethod := aCompiledMethod.
analyzedSourceRanges := aCollecitonOfAnalizedSourceRanges.
compiledMethodWasExecuted := false.! !
!MethodCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/3/2022 00:17:01'!
consolidateCoverageResults
^ analyzedSourceRanges
inject: Dictionary new
into: [ :coverageRatioBySourceRange :aSourceRange |
coverageRatioBySourceRange
at: aSourceRange
put: (self coverageRatioFor: aSourceRange).
coverageRatioBySourceRange ]! !
!MethodCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/3/2022 00:02:19'!
cover: aSourceRange declaredAt: declarationSourceRange by: anObject
^ anObject! !
!MethodCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:20:21'!
coverAll: sourceRanges by: anObject
^ anObject! !
!MethodCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/3/2022 00:01:59'!
coverAll: sourceRanges byLiteralOrPseudoVariable: anObject
^ anObject! !
!MethodCoverageReportBuilder methodsFor: 'registering code coverage' stamp: 'NPM 11/7/2022 02:25:11'!
coverAll: sourceRanges fromSending: aSelector to: aReceiver