# HG changeset patch # User Claus Gittinger # Date 1316248868 -7200 # Node ID 58506b6e5ede43e12e48d4d3e5c513a990c7d5df # Parent 9dbf4cbf5beaa357b3ee5cda666c334825f1dafc initial checkin diff -r 9dbf4cbf5bea -r 58506b6e5ede RegressionTests__STCCompilerTests.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RegressionTests__STCCompilerTests.st Sat Sep 17 10:41:08 2011 +0200 @@ -0,0 +1,91 @@ +"{ Package: 'exept:regression' }" + +"{ NameSpace: RegressionTests }" + +TestCase subclass:#STCCompilerTests + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'tests-Regression' +! + +!STCCompilerTests class methodsFor:'documentation'! + +documentation +" + documentation to be added. + + [author:] + cg + + [instance variables:] + + [class variables:] + + [see also:] + +" +! ! + +!STCCompilerTests methodsFor:'code templates'! + +nextLittleEndianNumber: n from:bytes + "stc generates wrong code for the following s := assignment" + + | s | + + s := 0. + n to: 1 by: -1 do: [:i | s := (s bitShift: 8) bitOr: (bytes at: i)]. + ^ s + + "Created: / 17-09-2011 / 10:32:29 / cg" +! ! + +!STCCompilerTests methodsFor:'tests'! + +test01_bitor_bug + "checks for an stc compiler bug (detected Sep 2011). + stc generates bad code for the bitOr expression in nextLittleEndianNumber" + + |val mthd| + + self class recompile:#'nextLittleEndianNumber:from:'. + + val := self nextLittleEndianNumber:4 from:#[1 2 3 4]. + self assert:(val = 16r04030201). + val := self nextLittleEndianNumber:8 from:#[1 2 3 4 5 6 7 8]. + self assert:(val = 16r0807060504030201). + + mthd := (self class compiledMethodAt:#'nextLittleEndianNumber:from:'). + (STCCompilerInterface new) + compileToMachineCode:mthd source + forClass:self class + selector:#'nextLittleEndianNumber:from:' + inCategory:mthd category + notifying:nil + install:true + skipIfSame:false + silent:true. + + val := self nextLittleEndianNumber:4 from:#[1 2 3 4]. + self assert:(val = 16r04030201). + val := self nextLittleEndianNumber:8 from:#[1 2 3 4 5 6 7 8]. + self assert:(val = 16r0807060504030201). + + " + self run:#test01_bitor_bug + self new test01_bitor_bug + " + + "Created: / 17-09-2011 / 10:32:18 / cg" +! ! + +!STCCompilerTests class methodsFor:'documentation'! + +version + ^ '$Header$' +! + +version_CVS + ^ '$Header$' +! !