<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le mer. 12 déc. 2018 à 09:13, Tobias Pape <<a href="mailto:Das.Linux@gmx.de">Das.Linux@gmx.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
Hi Nicolas,<br>
<br>
That's a good fix!<br>
<br>
Just one comment.<br>
<br>
> On 11.12.2018, at 22:52, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
> <br>
> <br>
> Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:<br>
> <a href="http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2492.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2492.mcz</a><br>
> <br>
> ==================== Summary ====================<br>
> <br>
> Name: VMMaker.oscog-nice.2492<br>
> Author: nice<br>
> Time: 11 December 2018, 10:52:00.075091 pm<br>
> UUID: 8fac9bb8-92b6-41f2-8646-230a75c04ee9<br>
> Ancestors: VMMaker.oscog-eem.2491<br>
> <br>
> Fix the FloatMathPluginTests and classify them in 'VMMaker-Tests'<br>
> <br>
> All the reference md5 hash have been produced with specific series of number generated with a specific Park-Miller Pseudo-Random-Number-Generator.<br>
> <br>
> The tests cannot rely on Random implementation (or should I say random implementation) which happens to change from time to time, so hardcode the PRNG.<br>
> <br>
> =============== Diff against VMMaker.oscog-eem.2491 ===============<br>
> <br>
> Item was changed:<br>
>  TestCase subclass: #FloatMathPluginTests<br>
> +     instanceVariableNames: 'seed'<br>
> -     instanceVariableNames: 'random'<br>
>       classVariableNames: ''<br>
>       poolDictionaries: ''<br>
> +     category: 'VMMaker-Tests'!<br>
> -     category: 'VMMaker-Plugins'!<br>
> <br>
>  !FloatMathPluginTests commentStamp: '<historical>' prior: 0!<br>
>  FloatMathPluginTests buildSuite run.!<br>
> <br>
> Item was changed:<br>
>  ----- Method: FloatMathPluginTests>>makeTestData:using:seed:rounds: (in category 'running') -----<br>
>  makeTestData: fileName using: aBlock seed: seed rounds: rounds<br>
>       | bytes out float result |<br>
>       bytes := ByteArray new: 8.<br>
>       out := FileStream newFileNamed: fileName.<br>
>       [<br>
>               out binary. <br>
>               out nextNumber: 4 put: rounds.<br>
>               out nextNumber: 4 put: seed.<br>
> +             self seed: seed.<br>
> -             random := Random seed: seed.<br>
<br>
This shadows the instVar now, right?<br>
I recon its nit a problem atm, but maybe we rename the Arg?<br>
<br>
Best regards<br>
        -Tobias<br>
<br></blockquote><div><br></div><div>Ah yes, good point, that's inelegant.</div><div>I did not remember having any warning when compiling (accepting) this code.</div><div>So maybe we can continue improvig our tools.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>               float := Float basicNew: 2.<br>
>               'Creating test data for: ', fileName <br>
>                       displayProgressAt: Sensor cursorPoint <br>
>                       from: 1 to: rounds during:[:bar|<br>
>                               1 to: rounds do:[:i|<br>
>                                       i \\ 10000 = 0 ifTrue:[bar value: i].<br>
> +                                     [1 to: 8 do:[:j| bytes at: j put: (self nextInt: 256)-1].<br>
> -                                     [1 to: 8 do:[:j| bytes at: j put: (random nextInt: 256)-1].<br>
>                                       float basicAt: 1 put: (bytes unsignedLongAt: 1 bigEndian: true).<br>
>                                       float basicAt: 2 put: (bytes unsignedLongAt: 5 bigEndian: true).<br>
>                                       float isNaN] whileTrue.<br>
>                                       result := aBlock value: float.<br>
>                                       out nextNumber: 4 put: (result basicAt: 1).<br>
>                                       out nextNumber: 4 put: (result basicAt: 2).<br>
>                               ].<br>
>                       ].<br>
>       ] ensure:[out close].<br>
>  !<br>
> <br>
> Item was added:<br>
> + ----- Method: FloatMathPluginTests>>nextInt: (in category 'rand') -----<br>
> + nextInt: anInteger<br>
> +     "Answer a random integer in the interval [1, anInteger]."<br>
> + <br>
> +     | a m q r lo hi aLoRHi |<br>
> +     a := 16r000041A7 asFloat.    " magic constant =      16807 "<br>
> +     m := 16r7FFFFFFF asFloat.    " magic constant = 2147483647 "<br>
> +     q := (m quo: a) asFloat.<br>
> +     r  := (m \\ a) asFloat.<br>
> +     hi := (seed quo: q) asFloat.<br>
> +     lo := seed - (hi * q).  " = seed rem: q"  <br>
> +     aLoRHi := (a * lo) - (r * hi).<br>
> +     seed := (aLoRHi > 0.0)<br>
> +             ifTrue:  [aLoRHi]<br>
> +             ifFalse: [aLoRHi + m].<br>
> +     ^ (seed / m * anInteger) truncated + 1!<br>
> <br>
> Item was changed:<br>
>  ----- Method: FloatMathPluginTests>>runTest: (in category 'running') -----<br>
>  runTest: aBlock<br>
>       | bytes out float result |<br>
>       bytes := ByteArray new: 8.<br>
>       out := WriteStream on: ByteArray new.<br>
>       float := Float basicNew: 2.<br>
>       1 to: 10000 do:[:i|<br>
> +             [1 to: 8 do:[:j| bytes at: j put: (self nextInt: 256)-1].<br>
> -             [1 to: 8 do:[:j| bytes at: j put: (random nextInt: 256)-1].<br>
>               float basicAt: 1 put: (bytes unsignedLongAt: 1 bigEndian: true).<br>
>               float basicAt: 2 put: (bytes unsignedLongAt: 5 bigEndian: true).<br>
>               float isNaN] whileTrue.<br>
>               result := [aBlock value: float] on: Error do:[:ex|<br>
>                       "we convert all errors into NaNs to have a value for testing"<br>
>                       ex return: Float nan.<br>
>               ].<br>
>               out nextNumber: 4 put: (result basicAt: 1).<br>
>               out nextNumber: 4 put: (result basicAt: 2).<br>
>       ].<br>
>       ^self md5HashMessage: out contents.!<br>
> <br>
> Item was added:<br>
> + ----- Method: FloatMathPluginTests>>seed: (in category 'rand') -----<br>
> + seed: anInteger<br>
> +     seed := anInteger!<br>
> <br>
> Item was changed:<br>
>  ----- Method: FloatMathPluginTests>>setUp (in category 'running') -----<br>
>  setUp<br>
> +     self seed: 253213.!<br>
> -     random := Random seed: 253213.!<br>
> <br>
> Item was changed:<br>
>  ----- Method: FloatMathPluginTests>>testTimesTwoPower (in category 'tests') -----<br>
>  testTimesTwoPower<br>
>       | hash |<br>
> +     hash := self runTest:[:f| self timesTwoPower: f with: (self nextInt: 200) - 100].<br>
> -     hash := self runTest:[:f| self timesTwoPower: f with: (random nextInt: 200) - 100].<br>
>       self assert: hash = 278837335583284459890979576373223649870.!<br>
> <br>
> Item was changed:<br>
>  ----- Method: FloatMathPluginTests>>verifyTestData:using: (in category 'running') -----<br>
>  verifyTestData: fileName using: aBlock<br>
>       | rounds seed bytes float result in expected count bits |<br>
>       in := [FileStream readOnlyFileNamed: fileName] <br>
>                       on: FileDoesNotExistException <br>
>                       do:[:ex| ex return: nil].<br>
>       in ifNil:[^nil].<br>
>       count := bits := 0.<br>
>       bytes := ByteArray new: 8.<br>
>       [<br>
>               in binary.<br>
>               rounds := in nextNumber: 4.<br>
>               seed := in nextNumber: 4.<br>
> +             self seed: seed.<br>
> -             random := Random seed: seed.<br>
>               float := Float basicNew: 2.<br>
>               expected := Float basicNew: 2.<br>
>               'Verifying test data from: ', fileName <br>
>                       displayProgressAt: Sensor cursorPoint <br>
>                       from: 1 to: rounds during:[:bar|<br>
>                               1 to: rounds do:[:i|<br>
>                                       i \\ 10000 = 0 ifTrue:[bar value: i].<br>
> +                                     [1 to: 8 do:[:j| bytes at: j put: (self nextInt: 256)-1].<br>
> -                                     [1 to: 8 do:[:j| bytes at: j put: (random nextInt: 256)-1].<br>
>                                       float basicAt: 1 put: (bytes unsignedLongAt: 1 bigEndian: true).<br>
>                                       float basicAt: 2 put: (bytes unsignedLongAt: 5 bigEndian: true).<br>
>                                       float isNaN] whileTrue.<br>
>                                       result := aBlock value: float.<br>
>                                       expected basicAt: 1 put: (in nextNumber: 4).<br>
>                                       expected basicAt: 2 put: (in nextNumber: 4).<br>
>                                       ((expected isNaN and:[result isNaN]) or:[expected = result]) ifFalse:[<br>
>                                               (expected basicAt: 1) = (result basicAt: 1)<br>
>                                                       ifFalse:[self error: 'Verification failure'].<br>
>                                               count := count + 1.<br>
>                                               bits := bits + ((expected basicAt: 2) - (result basicAt: 2)) abs.<br>
>                                       ].<br>
>                               ].<br>
>                       ].<br>
>       ] ensure:[in close].<br>
>       self assert: count = 0. "all the same"!<br>
> <br>
<br>
</blockquote></div></div>