Ticket #105: regression_fix_1_of_1_rev_03c52f59f5df_Issue__105__STC_compiled_forces_result_of______________to_be_a_boolean.patch
File regression_fix_1_of_1_rev_03c52f59f5df_Issue__105__STC_compiled_forces_result_of______________to_be_a_boolean.patch, 6.7 KB (added by , 8 years ago) |
---|
-
RegressionTests__CompilerTests2.st
# HG changeset patch # User Jan Vrany <jan.vrany@fit.cvut.cz> # Date 1471684576 -3600 # Sat Aug 20 10:16:16 2016 +0100 # Branch jv # Node ID 03c52f59f5df8db399528d83e0a101c27e99243d # Parent b711534dc296eb7579089a5a80cb2f958b3568ab Issue #105: STC compiled forces result of #<, #<=, ... to be a boolean Added tests for "comparing" selectors. More may be needed, based on a quick look to stc's `codeexpr.c`. diff -r b711534dc296 -r 03c52f59f5df RegressionTests__CompilerTests2.st
a b 5 5 TestCase subclass:#CompilerTests2 6 6 instanceVariableNames:'methods enabledJIT savedContext savedContextArgAndVarNames 7 7 savedContextArgAndVarValues savedContextArgAndVarValuesUsingEval 8 savedContextLine '8 savedContextLine stcGeneratedCSource' 9 9 classVariableNames:'' 10 10 poolDictionaries:'' 11 11 category:'tests-Regression-Compilers' … … 58 58 #stc....then the method is stc-compiled. 59 59 #jit....then the method is bytecode compiled and left 60 60 to the jitter 61 #bc.....the mthe method is bytecode compiled and marked61 #bc.....then the method is bytecode compiled and marked 62 62 as checked so JIT won't even try. 63 63 " 64 64 … … 67 67 Class withoutUpdatingChangesDo:[ 68 68 mode == #stc ifTrue:[ 69 69 ParserFlags withSTCCompilation:#always do:[ 70 m := self class compile: (mode, '_', source) classified: 'private - *dynamic*'. 70 MessageTracer wrapMethod: STCCompilerInterface >> #compileToC 71 onEntry:[:context | "nothing" ] 72 onExit: [:context :retval | stcGeneratedCSource := (context receiver instVarNamed: #cFileName) asFilename contents.retval ]. 73 [ 74 m := self class compile: (mode, '_', source) classified: 'private - *dynamic*'. 75 ] ensure:[ 76 MessageTracer unwrapMethod: STCCompilerInterface >> #compileToC 77 ]. 78 71 79 ]. 72 80 ] ifFalse:[ 73 81 ParserFlags withSTCCompilation:#never do:[ … … 80 88 ^m 81 89 82 90 "Created: / 25-04-2013 / 15:18:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" 91 "Modified: / 21-08-2016 / 08:34:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" 83 92 ! 84 93 85 94 currentLineNumber … … 650 659 ^ literal. 651 660 ! ! 652 661 662 !CompilerTests2 methodsFor:'private-mock methods-inlining / special selectors'! 663 664 < another 665 ^ self 666 667 "Created: / 20-08-2016 / 09:11:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" 668 ! 669 670 <= another 671 ^ self 672 673 "Created: / 20-08-2016 / 09:11:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" 674 "Modified: / 20-08-2016 / 10:11:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" 675 ! 676 677 = another 678 ^ self 679 680 "Created: / 20-08-2016 / 09:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" 681 "Modified: / 20-08-2016 / 10:11:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" 682 ! 683 684 > another 685 ^ self 686 687 "Created: / 20-08-2016 / 09:11:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" 688 "Modified: / 20-08-2016 / 10:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" 689 ! 690 691 >= another 692 ^ self 693 694 "Created: / 20-08-2016 / 09:11:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" 695 "Modified: / 20-08-2016 / 10:12:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" 696 ! 697 698 methodCallingBinaryRelopsOnObject: lhs andObject: rhs 699 | result | 700 701 result := Array new: 5. 702 703 lhs < rhs then:[ result at: 1 put: #< ]. 704 lhs <= rhs then:[ result at: 2 put: #<= ]. 705 lhs = rhs then:[ result at: 3 put: #= ]. 706 lhs > rhs then:[ result at: 4 put: #> ]. 707 lhs >= rhs then:[ result at: 5 put: #>= ]. 708 709 ^ result 710 711 "Created: / 20-08-2016 / 09:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" 712 ! 713 714 methodCallingBinaryRelopsOnObjectAndConstant: lhs 715 | result | 716 717 result := Array new: 5. 718 719 lhs < 1 then:[ result at: 1 put: #< ]. 720 lhs <= 2 then:[ result at: 2 put: #<= ]. 721 lhs = 3 then:[ result at: 3 put: #= ]. 722 lhs > 4 then:[ result at: 4 put: #> ]. 723 lhs >= 5 then:[ result at: 5 put: #>= ]. 724 725 ^ result 726 727 "Created: / 20-08-2016 / 09:17:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" 728 ! 729 730 then: aBlock 731 aBlock value 732 733 "Created: / 20-08-2016 / 10:09:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" 734 ! ! 735 653 736 !CompilerTests2 methodsFor:'setup'! 654 737 655 738 setUp … … 666 749 tearDown 667 750 savedContext := savedContextArgAndVarNames 668 751 := savedContextArgAndVarValues := savedContextArgAndVarValuesUsingEval 669 := savedContextLine := nil.752 := savedContextLine := stcGeneratedCSource := nil. 670 753 671 754 ObjectMemory justInTimeCompilation: enabledJIT. 672 755 Class withoutUpdatingChangesDo:[ … … 693 776 ] 694 777 695 778 "Created: / 26-10-2012 / 11:32:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" 696 "Modified: / 2 6-09-2014 / 12:59:58/ Jan Vrany <jan.vrany@fit.cvut.cz>"779 "Modified: / 20-08-2016 / 08:57:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" 697 780 ! ! 698 781 699 782 !CompilerTests2 methodsFor:'tests'! … … 1177 1260 "Modified: / 26-12-2015 / 07:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1178 1261 ! ! 1179 1262 1263 !CompilerTests2 methodsFor:'tests - inlining / special selectors'! 1264 1265 testRelopNotReturningBoolean01 1266 | expected returned | 1267 1268 expected := #( #< #<= #= #> #>= ). 1269 1270 #(bc stc) do:[:mode | 1271 self compile: (self class >> #methodCallingBinaryRelopsOnObjectAndConstant:) source mode: mode. 1272 returned := self perform: (mode , '_methodCallingBinaryRelopsOnObjectAndConstant:') asSymbol with: self. 1273 self assert: returned = expected. 1274 ] 1275 1276 "Created: / 21-08-2016 / 08:37:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1277 ! 1278 1279 testRelopNotReturningBoolean02 1280 | expected returned | 1281 1282 expected := #( #< #<= #= #> #>= ). 1283 1284 #(bc stc) do:[:mode | 1285 self compile: (self class >> #methodCallingBinaryRelopsOnObject:andObject:) source mode: mode. 1286 returned := self perform: (mode , '_methodCallingBinaryRelopsOnObject:andObject:') asSymbol with: self with: self. 1287 self assert: returned = expected. 1288 ] 1289 1290 "Created: / 21-08-2016 / 09:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1291 ! ! 1292 1180 1293 !CompilerTests2 methodsFor:'tests - line numbers'! 1181 1294 1182 1295 test_lineno_01_bci … … 1222 1335 m300 := self class >> #method_lineno_300. 1223 1336 1224 1337 self compile: m002 source mode: #stc. 1338 " 1339 stcGeneratedCSource asString inspect. 1340 " 1225 1341 self compile: m300 source mode: #stc. 1226 1342 1227 1343 self assert: (l := self stc_method_lineno_002) == 2. … … 1229 1345 1230 1346 "Created: / 12-04-2013 / 21:50:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1231 1347 "Modified: / 25-04-2013 / 15:22:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1348 "Modified (comment): / 20-08-2016 / 08:59:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" 1232 1349 ! ! 1233 1350 1234 1351 !CompilerTests2 methodsFor:'tests - literals'!