Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
c62e3467
Commit
c62e3467
authored
7 years ago
by
Raymond Toy
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for xoroshiro generator
parent
192fe3b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/rng.lisp
+55
-0
55 additions, 0 deletions
tests/rng.lisp
with
55 additions
and
0 deletions
tests/rng.lisp
0 → 100644
+
55
−
0
View file @
c62e3467
;; Tests for RNG
(
defpackage
:rng-tests
(
:use
:cl
:lisp-unit
))
(
in-package
"RNG-TESTS"
)
(
defun
64-bit-rng-state
(
rng
)
(
let
((
state
(
kernel::xoro-random-state-state
rng
)))
(
flet
((
convert
(
x
)
(
multiple-value-bind
(
hi
lo
)
(
kernel:double-float-bits
x
)
(
logior
(
ash
(
ldb
(
byte
32
0
)
hi
)
32
)
lo
))))
(
values
(
convert
(
aref
state
0
))
(
convert
(
aref
state
1
))))))
(
defun
64-bit-value
(
rng
)
(
logior
(
ash
(
kernel::xoroshiro-chunk
rng
)
32
)
(
kernel::xoroshiro-chunk
rng
)))
(
defvar
*test-state*
)
(
define-test
rng.initial-state
(
setf
*test-state*
(
kernel::make-xoroshiro-object
:state
(
kernel::init-xoro-state
#x12345678
)
:rand
0
:cached-p
nil
))
(
multiple-value-bind
(
s0
s1
)
(
64-bit-rng-state
*test-state*
)
(
assert-equal
#x38f1dc39d1906b6f
s0
)
(
assert-equal
#xdfe4142236dd9517
s1
)
(
assert-equal
0
(
kernel::xoro-random-state-rand
*test-state*
))
(
assert-equal
nil
(
kernel::xoro-random-state-cached-p
*test-state*
))))
(
define-test
rng.values-test
(
assert-equal
(
list
#x38f1dc39d1906b6f
#xdfe4142236dd9517
)
(
multiple-value-list
(
64-bit-rng-state
*test-state*
)))
(
assert-equal
0
(
kernel::xoro-random-state-rand
*test-state*
))
(
assert-equal
nil
(
kernel::xoro-random-state-cached-p
*test-state*
))
(
dolist
(
item
'
((
#x18d5f05c086e0086
(
#x228f4926843b364d
#x74dfe78e715c81be
))
(
#x976f30b4f597b80b
(
#x5b6bd4558bd96a68
#x567b7f35650aea8f
))
(
#xb1e7538af0e454f7
(
#x13e5253e242fac52
#xed380e70d10ab60e
))
(
#x011d33aef53a6260
(
#x9d0764952ca00d8a
#x5251a5cfedd2b4ef
))
(
#xef590a651a72c279
(
#xba4ef2b425bda963
#x172b965cf56c15ac
))
(
#xd17a89111b29bf0f
(
#x458277a5e5f0a21b
#xd1bccfad6564e8d
))
(
#x529e44a0bc46f0a8
(
#x2becb68d5a7194c7
#x3a6ec964899bb5f3
))
(
#x665b7ff1e40d4aba
(
#xededfd481d0a19fe
#x3ea213411827fe9d
))
(
#x2c9010893532189b
(
#xd7bb59bcd8fba26f
#x52de763d34fee090
))
(
#x2a99cffa0dfa82ff
(
#xf96e892c62d6ff2e
#xc0542ff85652f81e
))))
(
destructuring-bind
(
value
state
)
item
(
assert-equal
value
(
64-bit-value
*test-state*
))
(
assert-equal
state
(
multiple-value-list
(
64-bit-rng-state
*test-state*
))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment