summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics/rand/rand.adapt
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/numerics/rand/rand.adapt
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/numerics/rand/rand.adapt')
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp56
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp54
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp29
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp30
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp51
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp55
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp42
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp52
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp42
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp63
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp42
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp50
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp48
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp60
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp56
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp54
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp29
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp30
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp51
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp55
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp42
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp52
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp141
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp63
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp83
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp50
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp48
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp47
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp39
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp38
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp31
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp32
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp76
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp79
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp32
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp93
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp48
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp83
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp36
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp35
-rw-r--r--libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp44
43 files changed, 2190 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
new file mode 100644
index 00000000000..18c8947af6e
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine& operator=(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
new file mode 100644
index 00000000000..d6c64fa37dc
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
new file mode 100644
index 00000000000..d6b8b33ad01
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
new file mode 100644
index 00000000000..1e8e2fe6fbb
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
new file mode 100644
index 00000000000..dba254f1a73
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::ranlux24 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::ranlux48 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
new file mode 100644
index 00000000000..b64d4b31682
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> explicit discard_block_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux24 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux48 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
new file mode 100644
index 00000000000..ffdaebc1714
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
new file mode 100644
index 00000000000..2dada0d6345
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
new file mode 100644
index 00000000000..f819d6a9769
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e;
+ assert(e() == 15039276u);
+ assert(e() == 16323925u);
+ assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+ std::ranlux48 e;
+ assert(e() == 23459059301164ull);
+ assert(e() == 28639057539807ull);
+ assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
new file mode 100644
index 00000000000..4b742f06a5e
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const discard_block_engine<Engine, p, r>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// discard_block_engine<Engine, p, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
new file mode 100644
index 00000000000..2634aba3823
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::ranlux24::result_type,
+ std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::ranlux48::result_type,
+ std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
new file mode 100644
index 00000000000..6a5ff14f77a
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux24 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux48 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
new file mode 100644
index 00000000000..0da09a379e6
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux24 e1;
+ std::ranlux24 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux48 e1;
+ std::ranlux48 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
new file mode 100644
index 00000000000..53e4c29affc
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t block_size = p;
+// static constexpr size_t used_block = r;
+// static constexpr result_type min() { return Engine::min(); }
+// static constexpr result_type max() { return Engine::max(); }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ static_assert((E::block_size == 223), "");
+ static_assert((E::used_block == 23), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ static_assert((E::block_size == 389), "");
+ static_assert((E::used_block == 11), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
new file mode 100644
index 00000000000..e4cd4f7396b
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine& operator=(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
new file mode 100644
index 00000000000..e3e497ec8c6
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
new file mode 100644
index 00000000000..193f5c33ec1
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
new file mode 100644
index 00000000000..60a661d398f
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
new file mode 100644
index 00000000000..8e8d3091a4e
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
new file mode 100644
index 00000000000..7965f4397f5
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> explicit independent_bits_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
new file mode 100644
index 00000000000..ccb6f379d50
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 2066486613);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 18223106896348967647ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
new file mode 100644
index 00000000000..2a356a1c80d
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
new file mode 100644
index 00000000000..1c2b2a80c59
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 10>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 6958);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 100>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 66);
+}
+
+void
+test3()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 32, unsigned> E;
+
+ E e(5);
+ assert(e() == 5);
+}
+
+void
+test4()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 7, unsigned> E;
+
+ E e(129);
+ assert(e() == 1);
+}
+
+void
+test5()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 1, unsigned> E;
+
+ E e(6);
+ assert(e() == 1);
+}
+
+void
+test6()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 11, unsigned> E;
+
+ E e(6);
+ assert(e() == 1365);
+}
+
+void
+test7()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 32, unsigned> E;
+
+ E e(6);
+ assert(e() == 2863311530u);
+}
+
+void
+test8()
+{
+ typedef std::independent_bits_engine<std::mt19937, 64, unsigned long long> E;
+
+ E e(6);
+ assert(e() == 16470362623952407241ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
new file mode 100644
index 00000000000..9bcf0648824
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const independent_bits_engine<Engine, w, UIntType>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// independent_bits_engine<Engine, w, UIntType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
new file mode 100644
index 00000000000..78040ad987d
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned>::result_type,
+ unsigned>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned long long>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
new file mode 100644
index 00000000000..e8c24ca5fee
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
new file mode 100644
index 00000000000..ec83fff7f83
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
new file mode 100644
index 00000000000..20ca7d5510b
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+//
+// // engine characteristics
+// static constexpr result_type min() { return 0; }
+// static constexpr result_type max() { return 2^w - 1; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
new file mode 100644
index 00000000000..dae8c7c919a
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine& operator=(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
new file mode 100644
index 00000000000..c9e9893dee4
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
new file mode 100644
index 00000000000..a20c494f334
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Adaptor a(e);
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
new file mode 100644
index 00000000000..9811787821d
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
new file mode 100644
index 00000000000..32024949728
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1771550148 168070 677268843 1194115201 1259501992 "
+ "703671065 407145426 1010275440 1693606898 1702877348 745024267 "
+ "1793193459 416963415 664975744 742430420 1148079870 637806795 "
+ "1527921388 165317290 1791337459 1435426120 375508442 1863429808 "
+ "1910758855 653618747 991426424 578291095 1974930990 1157900898 "
+ "343583572 25567821 221638147 1335692731 1341167826 1019292670 "
+ "774852571 606325389 700907908 1211405961 1955012967 1403137269 "
+ "1010152376 1772753897 486628401 1145807831 1106352968 1560917450 "
+ "679350398 1819071734 1561434646 781928982 1427964481 1669276942 "
+ "811199786 1608612146 1272705739 1428231253 1857946652 2097152784 "
+ "197742477 1300609030 99924397 97128425 349867255 408729299 1860625187 "
+ "2018133942 1420442476 1948474080 1025729457 1583749330 15184745 "
+ "1806938869 1655319056 296727307 638820415 1383963552 880037807 "
+ "1075545360 1321008721 1507631161 597371974 544717293 340756290 "
+ "1899563128 1465595994 634440068 777915521 545718511 2135841687 "
+ "1902073804 712854586 135760289 1095544109 285050585 1956649285 "
+ "987446484 259432572 891434194 1488577086 330596852 801096775 "
+ "1458514382 1872871416 1682074633 1153627723 1538775345 51662594 "
+ "709823970 739804705 2114844452 1188863267 1037076781 1172179215 "
+ "1948572574 533634468 902793804 1283497773 273836696 315894151 "
+ "653420473 1954002600 1601768276 64415940 306945492 577163950 "
+ "210874151 813838307 857078006 1737226413 376658679 1868110244 "
+ "1117951768 1080937173 1746896638 1842856729 1883887269 2141922362 "
+ "1020763473 1872318475 978729834 1935067665 1189895487 1205729145 "
+ "1034046923 1788963337 188263312 898072753 1393688555 1119406056 "
+ "1900835472 1375045132 1312008157 559007303 2142269543 413383599 "
+ "628550348 573639243 1100665718 464587168 65992084 1027393936 "
+ "1641360472 1918007189 69800406 609352380 35938117 569027612 902394793 "
+ "1019770837 221470752 669768613 1839284764 1979413630 1335703733 "
+ "1526078440 1403144959 1139398206 753967943 1785700701 1187714882 "
+ "1063522909 1123137582 192083544 680202567 1109090588 327456556 "
+ "1709233078 191596027 1076438936 1306955024 1530346852 127901445 "
+ "8455468 377129974 1199230721 1336700752 1103107597 703058228 "
+ "844612202 530372344 1910850558 47387421 1871435357 1168551137 "
+ "1101007744 1918050856 803711675 309982095 73743043 301259382 "
+ "1647477295 1644236294 859823662 638826571 1487427444 335916581 "
+ "15468904 140348241 895842081 410006250 1847504174 536600445 "
+ "1359845362 1400027760 288242141 1910039802 1453396858 1761991428 "
+ "2137921913 357210187 1414819544 1933136424 943782705 841706193 "
+ "1081202962 1919045067 333546776 988345562 337850989 314809455 "
+ "1750287624 853099962 1450233962 142805884 1399258689 247367726 "
+ "2128513937 1151147433 654730608 351121428 12778440 18876380 "
+ "1575222551 587014441 411835569 380613902 1771550148";
+ std::knuth_b e1(10);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
new file mode 100644
index 00000000000..a08df07b3a8
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1894661934 884942216 1899568837 1561547157 525417712 "
+ "242729120 1476874187 1208468883 1983666902 1953485886 1507290666 "
+ "1317123450 632390874 696850315 1734917114 218976032 1690682513 "
+ "1944862534 456017951 2072049961 1348874775 1700965693 828093387 "
+ "2071522749 1077957279 1055942061 413360419 238964088 475007126 "
+ "1248050783 1516729632 1044035134 9617501 580065782 1737324341 "
+ "2022534575 219953662 941840747 415472792 1381878747 200458524 "
+ "1852054372 1849850586 1318041283 1026024576 101363422 660501483 "
+ "705453438 298717379 1873705814 673416290 868766340 614560427 "
+ "1668238166 532360730 969915708 1972423626 1966307090 97417947 "
+ "920896215 588041576 495024338 522400288 1068491480 878048146 "
+ "1995051285 17282737 560668414 2143274709 127339385 1299331283 "
+ "99667038 66663006 1566161755 773555006 272986904 1065825536 "
+ "1168683925 1185292013 1144552919 1489883454 811887358 279732868 "
+ "628609193 1562647158 1833265343 1742736292 639398211 357562689 "
+ "896869717 501615326 1775469607 1032409784 43371928 955037563 "
+ "1023543663 1354331571 1071539244 562210166 138213162 1518791327 "
+ "1335204647 1727874626 2114964448 1058152392 1055171537 348065433 "
+ "190278003 399246038 1389247438 1639480282 382424917 2144508195 "
+ "1531185764 1342593547 1359065400 1176108308 1412845568 968776497 "
+ "5573525 1332437854 323541262 329396230 2097079291 1110029273 "
+ "1071549822 739994612 1011644107 1074473050 478563727 894301674 "
+ "290189565 280656618 1121689914 1630931232 579945916 1870220126 "
+ "71516543 1535179528 1893792038 1107650479 1893348357 93154853 "
+ "138035708 683805596 1535656875 1326628479 1469623399 1751042846 "
+ "661214234 1947241260 1780560187 690441964 1403944207 1687457460 "
+ "1428487938 1877084153 1618585041 1383427538 461185097 869443256 "
+ "1254069404 1739961370 1245924391 138197640 1257913073 1915996843 "
+ "641653536 1755587965 1889101622 1732723706 2009073422 1611621773 "
+ "315899200 738279016 94909546 1711873548 1620302377 181922632 "
+ "1704446343 1345319468 2076463060 357902023 157605314 1025175647 "
+ "865799248 138769064 124418006 1591838311 675218651 1096276609 "
+ "1858759850 732186041 769493777 735387805 894450150 638142050 "
+ "720101232 1671055379 636619387 898507955 118193981 63865192 "
+ "1787942091 204050966 2100684950 1580797970 1951284753 1020070334 "
+ "960149537 1041144801 823914651 558983501 1742229329 708805658 "
+ "804904097 1023665826 1260041465 1180659188 590074436 301564006 "
+ "324841922 714752380 1967212989 290476911 815113546 815183409 "
+ "1989370850 1182975807 870784323 171062356 1711897606 2024645183 "
+ "1333203966 314683764 1785282634 603713754 1904315050 1874254109 "
+ "1298675767 1967311508 1946285744 753588304 1847558969 1457540010 "
+ "528986741 97857407 1864449494 1868752281 1171249392 1353422942 "
+ "832597170 457192338 335135800 1925268166 1845956613 296546482 "
+ "1894661934";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::knuth_b e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
new file mode 100644
index 00000000000..7b4bc582095
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2(std::minstd_rand0::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 152607844u);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
new file mode 100644
index 00000000000..6e04e26c7e5
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
new file mode 100644
index 00000000000..c218c17dde6
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+
+ E e;
+ assert(e() == 152607844u);
+}
+
+void
+test2()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 101> E;
+ E e;
+ e.discard(400);
+ assert(e() == 501);
+}
+
+void
+test3()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 100> E;
+ E e;
+ e.discard(400);
+ assert(e() == 500);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
new file mode 100644
index 00000000000..6c8fdb998bf
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const shuffle_order_engine<Engine, k>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// shuffle_order_engine<Engine, k>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
new file mode 100644
index 00000000000..3271d933cb2
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long, 0, 10>, 16>::result_type,
+ unsigned long>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long long, 0, 10>, 16>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
new file mode 100644
index 00000000000..57ded845e1e
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::knuth_b E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
new file mode 100644
index 00000000000..4b4b099bce4
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::knuth_b e1;
+ std::knuth_b e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
new file mode 100644
index 00000000000..eb42d644d30
--- /dev/null
+++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t table_size = k;
+// static constexpr result_type min() { return Engine::min; }
+// static constexpr result_type max() { return Engine::max; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ static_assert(E::table_size == 256, "");
+ /*static_*/assert((E::min() == 1)/*, ""*/);
+ /*static_*/assert((E::max() == 2147483646)/*, ""*/);
+ where(E::table_size);
+}
+
+int main()
+{
+ test1();
+}
OpenPOWER on IntegriCloud