Skip to content

Commit 428611d

Browse files
authored
Merge pull request #7 from DurieuxPol/fix/seed0
Use 0 as random seed for pharo12 compatibility
2 parents e4d160c + 5786864 commit 428611d

14 files changed

Lines changed: 91 additions & 78 deletions

src/Math-Tests-RandomNumbers/PMBernoulliGeneratorTest.class.st

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,28 @@
22
A BernoulliGeneratorTest is a test class for testing the behavior of BernoulliGenerator
33
"
44
Class {
5-
#name : #PMBernoulliGeneratorTest,
6-
#superclass : #TestCase,
7-
#category : #'Math-Tests-RandomNumbers'
5+
#name : 'PMBernoulliGeneratorTest',
6+
#superclass : 'TestCase',
7+
#category : 'Math-Tests-RandomNumbers',
8+
#package : 'Math-Tests-RandomNumbers'
89
}
910

10-
{ #category : #tests }
11+
{ #category : 'tests' }
1112
PMBernoulliGeneratorTest >> testNextYieldsOneOrZero [
1213
| gen |
1314
gen := PMBernoulliGenerator fair.
1415
self should: [ | x | x := gen next.
1516
(x = 0) or: [x = 1]].
1617
]
1718

18-
{ #category : #tests }
19+
{ #category : 'tests' }
1920
PMBernoulliGeneratorTest >> testOneProbabilityGivesOneNext [
2021
| g |
2122
g := PMBernoulliGenerator withProbability: 1.
2223
self assert: g next equals: 1
2324
]
2425

25-
{ #category : #tests }
26+
{ #category : 'tests' }
2627
PMBernoulliGeneratorTest >> testProbabilityIsMutable [
2728
| g |
2829
g := PMBernoulliGenerator withProbability: 0.0.
@@ -33,7 +34,7 @@ PMBernoulliGeneratorTest >> testProbabilityIsMutable [
3334
self assert: g probability equals: 1
3435
]
3536

36-
{ #category : #tests }
37+
{ #category : 'tests' }
3738
PMBernoulliGeneratorTest >> testZeroProbabilityGivesZeroNext [
3839
| g |
3940
g := PMBernoulliGenerator withProbability: 0.0.

src/Math-Tests-RandomNumbers/PMBinomialGeneratorTest.class.st

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMBinomialGeneratorTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMBinomialGeneratorTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [
910
| g numberOfTrials |
1011
g := PMBinomialGenerator new.
@@ -20,7 +21,7 @@ PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlway
2021
self assert: g next equals: numberOfTrials
2122
]
2223

23-
{ #category : #tests }
24+
{ #category : 'tests' }
2425
PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwaysReturnZero [
2526
| g numberOfTrials |
2627
g := PMBinomialGenerator new.
@@ -36,13 +37,13 @@ PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwa
3637
self assert: g next equals: 0
3738
]
3839

39-
{ #category : #tests }
40+
{ #category : 'tests' }
4041
PMBinomialGeneratorTest >> testSampleMeanConvergesToExpectedValue [
4142
"Its purpose is to verify correct convergence of the binomial distribution,
4243
should be Normal (np, np(1-p))"
4344

4445
| gen sample probabilityOfSuccess numberOfTrials |
45-
probabilityOfSuccess := (Random seed: 0.0) next sqrt.
46+
probabilityOfSuccess := (Random seed: 0) next sqrt.
4647
numberOfTrials := 1000.
4748
gen := PMBinomialGenerator
4849
numberOfTrials: numberOfTrials

src/Math-Tests-RandomNumbers/PMConstantGeneratorTest.class.st

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMConstantGeneratorTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMConstantGeneratorTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMConstantGeneratorTest >> testConstantGenerator [
910
| g |
1011
g := PMConstantGenerator new.

src/Math-Tests-RandomNumbers/PMExponentialGeneratorTest.class.st

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
A PMExponentialGeneratorTest is a test class for testing the behavior of PMExponentialGenerator
33
"
44
Class {
5-
#name : #PMExponentialGeneratorTest,
6-
#superclass : #TestCase,
7-
#category : #'Math-Tests-RandomNumbers'
5+
#name : 'PMExponentialGeneratorTest',
6+
#superclass : 'TestCase',
7+
#category : 'Math-Tests-RandomNumbers',
8+
#package : 'Math-Tests-RandomNumbers'
89
}
910

10-
{ #category : #tests }
11+
{ #category : 'tests' }
1112
PMExponentialGeneratorTest >> testGenerator [
1213
| eg |
1314
eg := PMExponentialGenerator new.
@@ -19,15 +20,15 @@ PMExponentialGeneratorTest >> testGenerator [
1920
self assert: (eg next isKindOf: Number)
2021
]
2122

22-
{ #category : #tests }
23+
{ #category : 'tests' }
2324
PMExponentialGeneratorTest >> testPeekIsIdempotent [
2425
| eg |
2526
eg := PMExponentialGenerator new.
2627
self assert: eg peek equals: eg peek.
2728
self assert: eg peek equals: eg next
2829
]
2930

30-
{ #category : #tests }
31+
{ #category : 'tests' }
3132
PMExponentialGeneratorTest >> testSampleMeanConvergesToExpectedValue [
3233
"testing a random sample seems suspect. We use a 5% interval here"
3334

src/Math-Tests-RandomNumbers/PMFishmanMooreRandomGeneratorTest.class.st

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMFishmanMooreRandomGeneratorTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMFishmanMooreRandomGeneratorTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMFishmanMooreRandomGeneratorTest >> testNext [
910
| random expectedNumbers |
1011
random := PMFishmanMooreRandomGenerator new.

src/Math-Tests-RandomNumbers/PMGaussianGeneratorTest.class.st

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
Class {
2-
#name : #PMGaussianGeneratorTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMGaussianGeneratorTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #utilities }
8+
{ #category : 'utilities' }
89
PMGaussianGeneratorTest >> assertSampleGeneratedBy: aGenerator convergesToExpectedValue: expectedValue andStandardDeviation: stdDeviation [
910
| sample |
1011
sample := PMRandomSample ofSize: 10000 usingGenerator: aGenerator.
1112
self assert: (expectedValue - sample average) abs <= 0.2.
1213
self assert: (sample stdev - stdDeviation) abs <= 1
1314
]
1415

15-
{ #category : #tests }
16+
{ #category : 'tests' }
1617
PMGaussianGeneratorTest >> testSampleMeanAndStandardDeviationConvergeToDistributionValues [
1718
| mean standardDeviation g |
1819
mean := 147.

src/Math-Tests-RandomNumbers/PMLehmerRandomTest.class.st

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMLehmerRandomTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMLehmerRandomTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMLehmerRandomTest >> testNextBetweenZeroAndOne [
910
| g |
1011
g := PMLehmerRandomGenerator new.
@@ -13,14 +14,14 @@ PMLehmerRandomTest >> testNextBetweenZeroAndOne [
1314
self assert: g next < 1 ]
1415
]
1516

16-
{ #category : #tests }
17+
{ #category : 'tests' }
1718
PMLehmerRandomTest >> testPeekAnswersSameAsNext [
1819
| g |
1920
g := PMLehmerRandomGenerator new.
2021
self assert: g peek equals: g next
2122
]
2223

23-
{ #category : #tests }
24+
{ #category : 'tests' }
2425
PMLehmerRandomTest >> testPeekIsIdempotent [
2526
| g |
2627
g := PMLehmerRandomGenerator new.

src/Math-Tests-RandomNumbers/PMLinearCongruentialRandomTest.class.st

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMLinearCongruentialRandomTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMLinearCongruentialRandomTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMLinearCongruentialRandomTest >> testNextBetweenZeroAndOne [
910
| g |
1011
g := PMLinearCongruentialRandomGenerator new.
@@ -13,14 +14,14 @@ PMLinearCongruentialRandomTest >> testNextBetweenZeroAndOne [
1314
self assert: g next <= 1 ]
1415
]
1516

16-
{ #category : #tests }
17+
{ #category : 'tests' }
1718
PMLinearCongruentialRandomTest >> testPeekAnswersSameAsNext [
1819
| g |
1920
g := PMLinearCongruentialRandomGenerator new.
2021
self assert: g peek equals: g next
2122
]
2223

23-
{ #category : #tests }
24+
{ #category : 'tests' }
2425
PMLinearCongruentialRandomTest >> testPeekIsIdempotent [
2526
| g |
2627
g := PMLinearCongruentialRandomGenerator new.

src/Math-Tests-RandomNumbers/PMMersenneTwisterRandomTest.class.st

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMMersenneTwisterRandomTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMMersenneTwisterRandomTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMMersenneTwisterRandomTest >> testNext10BetweenZeroAndTen [
910
| g |
1011
g := PMMersenneTwisterRandomGenerator new.
@@ -15,7 +16,7 @@ PMMersenneTwisterRandomTest >> testNext10BetweenZeroAndTen [
1516
self assert: value < 10 ]
1617
]
1718

18-
{ #category : #tests }
19+
{ #category : 'tests' }
1920
PMMersenneTwisterRandomTest >> testNextBetweenZeroAndOne [
2021
| g |
2122
g := PMMersenneTwisterRandomGenerator new.
@@ -24,7 +25,7 @@ PMMersenneTwisterRandomTest >> testNextBetweenZeroAndOne [
2425
self assert: g next < 1 ]
2526
]
2627

27-
{ #category : #tests }
28+
{ #category : 'tests' }
2829
PMMersenneTwisterRandomTest >> testNextFloatExcludeUpper [
2930
"this revealed a bug in early versions, excludeUpper was producing between 0 and 2"
3031

src/Math-Tests-RandomNumbers/PMNumberGeneratorTest.class.st

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMNumberGeneratorTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-RandomNumbers'
2+
#name : 'PMNumberGeneratorTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-RandomNumbers',
5+
#package : 'Math-Tests-RandomNumbers'
56
}
67

7-
{ #category : #tests }
8+
{ #category : 'tests' }
89
PMNumberGeneratorTest >> testPeekIsIdempotent [
910
"every subclass should implement some basic behavior."
1011

0 commit comments

Comments
 (0)