SlideShare a Scribd company logo
1 of 53
Your systems. Working as one.
Sumant Tambe, PhD
Principal Research Engineer and Microsoft VC++ MVP
Real-Time Innovations, Inc.
@sutambe
Oct. 3, 2015
10/4/2015 © 2015 RTI 2
LEESA 2008 Rx4DDS 2014 RefleX 2015
Alternative Title
10/4/2015 © 2015 RTI 3
Author
Blogger Open-Source
LEESA
(C++)
Rx4DDS
(C++11, C#, JavaScript)
(C++11)
Why should you care?
• If you write software for living and if you are
serious about any of the following
– Bug-free, Expressive code
– Productivity
• Modularity
• Reusability
• Extensibility
• Maintainability
– Performance/latency
• Multi-core scalability
– and having fun while doing that!
10/4/2015 © 2015 RTI 4
Agenda
• Property-based Testing
• The need for composable generators
• Design/Implementation of the generator library
• Mathematics of API design
– Functor, Monoid, and Monad
• Generators at compile-time (type generators)
10/4/2015 © 2015 RTI 5
What’s a Property
• Reversing a linked-list twice has no effect
– reverse(reverse(list)) == list
• Compression can make things smaller
– compress(input).size <= input.size
• Round-trip serialization/deserialization has no
effect
– deserialize(serialize(input)) == input
10/4/2015 © 2015 RTI 6
Testing RefleX
• RefleX is short for Reflection for DDS-Xtypes
• Serialization and Deserialization
– Serializes types and data
– Works off of C++ struct/classes directly
• C++11/14
• Link
10/4/2015 © 2015 RTI 7
RefleX Example
10/4/2015 © 2015 RTI 8
class ShapeType
{
std::string color_;
int x_, y_, shapesize_;
public:
ShapeType() {}
ShapeType(const std::string & color,
int x, int y, int shapesize)
: color_(color), x_(x), y_(y),
shapesize_(shapesize)
{}
std::string & color();
int & x();
int & y();
int & shapesize();
};
#include "reflex.h"
REFLEX_ADAPT_STRUCT(
ShapeType,
(std::string, color(), KEY)
(int, x())
(int, y())
(int, shapesize()))
A property-test in RefleX
10/4/2015 © 2015 RTI 9
template <class T>
void test_roundtrip_property(const T & in)
{
reflex::TypeManager<T> tm;
reflex::SafeDynamicData<T> safedd =
tm.create_dynamicdata(in);
reflex::read_dynamicdata(out, safedd);
assert(in == out);
}
Property-based Testing
• Complementary to traditional example-based testing
• Specify post-conditions that must hold no matter
what
• Encourages the programmer to think harder about
the code
• More declarative
• Need data generators to produce inputs
• Free reproducers!
– Good property-based testing frameworks shrink inputs to
minimal automatically
• Famous: Haskell’s QuickCheck, Scala’s ScalaTest
10/4/2015 © 2015 RTI 10
A property-test in RefleX
10/4/2015 © 2015 RTI 11
template <class T>
void test_roundtrip_property(const T & in)
{
reflex::TypeManager<T> tm;
reflex::SafeDynamicData<T> safedd =
tm.create_dynamicdata(in);
reflex::read_dynamicdata(out, safedd);
assert(in == out);
}
What’s the input data?
What are the input types?
10/4/2015 © 2015 RTI 12
Random Integer Generator
10/4/2015 © 2015 RTI 13
• The simplest data generator
size_t seed = time(NULL);
srandom(seed);
size_t rand()
{
return random();
}
• Alternatively
size_t seed =
std::chrono::system_clock::now().time_since_epoch().count();
size_t rand()
{
static std::mt19937 mt(seed);
return mt();
}
Fundamental Data Generators
10/4/2015 © 2015 RTI 14
• A bool generator
bool bool_gen() {
return rand() % 2;
}
• An uppercase character generator
char uppercase_gen() // A=65, Z=90
return static_cast<char>(‘A’ + rand() % 26))
}
Data Generators
10/4/2015 © 2015 RTI 15
• A range generator
– Generates any number in the range
int range_gen(int lo, int hi)
return lo + rand() % (hi – lo + 1);
}
• Inconvenient because args must be passed every time
Use state!
Closure as generator
10/4/2015 © 2015 RTI 16
• A stateful range generator
– Generates a random number in the given range
auto make_range_gen(int lo, int hi)
return [lo, hi]() {
return lo + rand() % (hi – lo + 1);
}
}
auto r = range_gen(20, 25);
std::cout << r(); // one of 20, 21, 22, 23, 24, 25
Closure as generator
10/4/2015 © 2015 RTI 17
• The oneof generator
template <class T>
auto make_oneof_gen(std::initializer_list<T> list)
{
return [options = std::vector<T>(list)]() {
return *(options.begin() + rand() % options.size());
};
}
auto days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” }
auto gen = make_oneof_gen(days);
std::cout << gen(); // one of Sun, Mon, Tue, Wed, Thu, Fri, Sat
10/4/2015 © 2015 RTI 18
“Closures are poor man's
objects; Objects are poor
man's closure”
-- The venerable master Qc Na
Source Google images
Closure vs Object
• Is function/closure a sufficient abstraction for
any generator?
[]() {
return blah;
}
• Answer depends upon your language
– No. In C++
10/4/2015 © 2015 RTI 19
The Generator Class Template
10/4/2015 © 2015 RTI 20
template <class T, class GenFunc>
struct Gen : private GenFunc
{
typedef T value_type;
explicit Gen(GenFunc func)
: GenFunc(std::move(func))
{ }
T generate()
{
return GenFunc::operator()();
}
auto map(...) const;
auto zip_with(...) const;
auto concat(...) const;
auto take(...) const;auto concat_map(...) const;
auto reduce(...) const;
auto where(...) const;
auto scan(...) const;
};
Creating Gen<T> from lambdas
template <class GenFunc>
auto make_gen_from(GenFunc&& func)
{
return Gen<decltype(func()), GenFunc>
(std::forward<GenFunc>(func));
}
template <class Integer>
auto make_range_gen(Integer lo, Integer hi)
{
return make_gen_from([lo, hi]() {
return static_cast<Integer>(lo + rand() % (hi - lo));
});
}
10/4/2015 © 2015 RTI 21
Composing Generators
• Producing complex Generators from one or
more simpler Generators
10/4/2015 © 2015 RTI 22
Generator
map
reduce
concat
where
zip_with
concat_map
take
scan
Mapping over a generator
10/4/2015 © 2015 RTI 23
vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”,
“Thu”, “Fri”, “Sat” };
auto range_gen = gen::make_range_gen(0,6);
// random numbers in range 0..6
auto day_gen = range_gen.map([&](int i) { return days[i]; });
// random days in range “Sun” to “Sat”
while(true)
std::cout << day_gen.generate();
// random days in range “Sun” to “Sat”
Gen<int>  Gen<string>
f(int  string)
std::function<string(int)>
10/4/2015 © 2015 RTI 24
Generator is a
You can
over it.
Functor Laws
• Composition Law
gen.map(f).map(g) == gen.map(g o f)
10/4/2015 © 2015 RTI 25
auto DAY_gen = range_gen
.map([&](int i) { return days[i]; });
.map([](const string & str) {
return std::toupper(str, std::locale());
});
auto DAY_gen = range_gen.map([&](int i) {
return std::to_upper(days[i], std::locale());
});
Functor Laws
• Identity Law
gen.map(a -> a) == gen
10/4/2015 © 2015 RTI 26
auto gen2 == gen.map([](auto a) { return a; });
• Both gen and gen2 will generate the same data
– Their identities are different but they are still the same
Implementing map
template <class T>
template <class Func>
auto Gen<T>::map(Func&& func) const
{
return make_gen_from(
[self = *this,
func = std::forward<Func>(func)]() mutable {
return func(self.generate());
});
}
10/4/2015 © 2015 RTI 27
Concatenating generators
10/4/2015 © 2015 RTI 28
vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”,
“Thu”, “Fri”, “Sat” };
auto day_gen = gen::make_inorder_gen(days)
// Sun,Mon,...,Sat
vector<string> months= { “Jan”, “Feb”, “Mar”, “Apr”,
“May”, “Jun”, “Jul”, “Aug”,
“Sept”, “Oct”, “Nov”, “Dec” };
auto month_gen = gen::make_inorder_gen(months);
auto concat_gen = days_gen.concat(month_gen);
for(int i = 0; i < 19; ++i)
std::cout << concat_gen.generate();
// Sun,Mon,...,Sat,Jan,Feb,Mar,...,Dec
10/4/2015 © 2015 RTI 29
Generator is a
Monoid Laws
• Identity Law
M o id = id o M = M
• Binary operation o = append
• Appending to identity (either way) must yield
the same generator
10/4/2015 © 2015 RTI 30
auto identity = gen::make_empty_gen<int>();
gen::make_inorder_gen({ 1, 2, 3}).append(identity)
==
identity.append(gen::make_inorder_gen({ 1, 2, 3});
Monoid Laws
• Associative Law
(f o g) o h = f o (g o h)
• Binary operation o = append
• Order of operation does not matter. (The order of
operands does)
– Not to be confused with commutative property where the order of
operands does not matter
10/4/2015 © 2015 RTI 31
auto f = gen::make_inorder_gen({ 1, 2});
auto g = gen::make_inorder_gen({ 3, 4});
auto h = gen::make_inorder_gen({ 5, 6});
(f.append(g)).append(h)
==
f.append(g.append(h));
Generator Identity make_empty_gen
template <class T>
auto make_empty_gen()
{
return make_gen_from([]() {
throw std::out_of_range("empty generator!");
return std::declval<T>();
});
}
10/4/2015 © 2015 RTI 32
Zipping Generators
10/4/2015 © 2015 RTI 33
auto x_gen = gen::make_stepper_gen(0,100);
auto y_gen = gen::make_stepper_gen(0,200,2);
auto point_gen =
x_gen.zip_with([](int x, int y)
return std::make_pair(x, y);
}, y_gen);
for(auto _: { 1,2,3 })
std::cout << point_gen.generate(); // {0,0}, {1,2}, {3,4}
end
Implementing zip_with
template <class T>
template <class Zipper, class... GenList>
auto Gen<T>::zip_with(Zipper&& func, GenList&&... genlist) const
{
return make_gen_from(
[self = *this,
genlist...,
func = std::forward<Zipper>(func)]() mutable {
return func(self.generate(), genlist.generate()...);
});
}
10/4/2015 © 2015 RTI 34
10/4/2015 © 2015 RTI 35
Generator is a
Dependent Generators (concat_map)
auto triangle_gen =
gen::make_inorder_gen({1,2,3,4,5,4,3,2,1})
.concat_map([](int i) {
std::cout << "n";
return gen::make_stepper_gen(1, i);
});
try {
while(true)
std::cout << triangle_gen.generate();
}
catch(std::out_of_range &) {
}
10/4/2015 © 2015 RTI 36
1
12
123
1234
12345
1234
123
12
1
Monad Laws
auto f = [](int i) { return gen::make_stepper_gen(1, i); };
auto g = [](int i) { return gen::make_stepper_gen(i, 1, -1); };
auto M = gen::make_single_gen(300);
// left identity
is_same(M.concat_map(f), f(300));
// right identity
is_same(M.concat_map([](int i) {
return gen::make_single_gen(i);
}), M);
// associativity
is_same(M.concat_map(f).concat_map(g),
M.concat_map([f,g](int i) mutable {
return f(i).concat_map(g);
}));
10/4/2015 © 2015 RTI 37
10/4/2015 © 2015 RTI 38
The Mathematics of the Generator API
Generators
• General design principal
– Create a language to solve a problem
– API is the language
– Reuse parsing/compilation of the host language (duh!)
• The “language” of Generators
– Primitive values are basic generators
– Complex values are composite generators
– All APIs result in some generator
• Especially, map, zip, reduce, etc.
– I.e., generators form an algebra
10/4/2015 © 2015 RTI 39
Algebra
A first-class abstraction
+
Compositional* API
10/4/2015 © 2015 RTI 40
*Composition based on mathematical concepts
10/4/2015 © 2015 RTI 41
What Math Concepts?
• Algebraic Structures from Category Theory
–Monoid
–Functor
–Monad
–Applicative
• Where to begin?
–Haskell
–But innocent should start with Scala perhaps
Back to the property-test in RefleX
10/4/2015 © 2015 RTI 42
template <class T>
void test_roundtrip_property(const T & in)
{
reflex::TypeManager<T> tm;
reflex::SafeDynamicData<T> safedd =
tm.create_dynamicdata(in);
reflex::read_dynamicdata(out, safedd);
assert(in == out);
}
What’s the input data?
What are the input types?
10/4/2015 © 2015 RTI 43
if we can generate
we can generate
Random Numbers at Compile-time
#include <stdio.h>
enum test { Foo = RANDOM };
int main(void)
{
enum test foo = Foo;
printf("foo = %dn", foo);
return 0;
}
10/4/2015 © 2015 RTI 44
$ gcc –DRANDOM=$RANDOM main.c –o main
$ ./main
foo = 17695
Random Numbers at Compile-time
#include <stdio.h>
enum test { Foo = RANDOM,
Bar = LFSR(Foo) };
int main(void) {
enum test foo = Foo;
enum test bar = Bar;
printf("foo = %d, bar = %dn", foo, bar);
}
10/4/2015 © 2015 RTI 45
#define LFSR_bit(prev)
(((prev >> 0) ^ (prev >> 2) ^ (prev >> 3) ^ (prev >> 5)) & 1)
#define LFSR(prev)
((prev >> 1) | (LFSR_bit(prev) << 15))
$ gcc –DRANDOM=$RANDOM main.c –o main
$ ./main
foo = 17695, bar = 41615
Could be
constexpr
Linear Feedback Shift Register (LFSR)
• Simple random number generator
• 4 bit Fibonacci LFSR
• Feedback polynomial = X4 + X3 + 1
• Taps 4 and 3
10/4/2015 © 2015 RTI 46Image source: wikipedia
Linear Feedback Shift Register (LFSR)
• Live code feedback polynomial (16 bit)
– X16 + X14 + X13 + X11 + 1
• Taps: 16, 14, 13, and 11
10/4/2015 © 2015 RTI 47Image source: wikipedia
Random Type Generation at Compile-Time
template <int I> struct TypeMap;
template <> struct TypeMap<0> {
typedef int type;
};
template <> struct TypeMap<1> {
typedef char type;
};
template <> struct TypeMap<2> {
typedef float type;
};
template <> struct TypeMap<3> {
typedef double type;
};
10/4/2015 © 2015 RTI 48
Random Type Generation at Compile-Time
#include <boost/core/demangle.hpp>
template <int seed>
struct RandomTuple {
typedef typename TypeMap<LFSR(seed) % 4>::type First;
typedef typename TypeMap<LFSR(LFSR(seed)) % 4>::type Second;
typedef typename TypeMap<LFSR(LFSR(LFSR(seed))) % 4>::type Third;
typedef std::tuple<First, Second, Third> type;
};
10/4/2015 © 2015 RTI 49
$ g++ –DRANDOM=$RANDOM main.cpp –o main
$ ./main
foo = 11660, bar = 5830
tuple = std::tuple<float, double, char>
int main(void) {
auto tuple = RandomTuple<RANDOM>::type();
printf("tuple = %s",
boost::core::demangle(typeid(tuple).name()).c_str());
}
Live code
Tuple Value Generator (zip)
template <class... Args>
struct GenFactory<std::tuple<Args...>>
{
static auto make()
{
return make_zip_gen([](auto&&... args) {
return std::make_tuple(std::forward<decltype(args)>(args)...);
},
GenFactory<Args>::make()...);
}
};
int main(void) {
auto tuple_gen = GenFactory<RandomTuple<RANDOM>::type>::make();
auto tuple = tuple_gen.generate();
}
10/4/2015 © 2015 RTI 50
Type Generators Demystified
• Random seed as command line #define
• Compile-time random numbers using LFSR
• C++ meta-programming for type synthesis
• std::string generator for type names and
member names
• RefleX to map types to typecode and dynamic data
• Source: https://github.com/sutambe/generators
10/4/2015 © 2015 RTI 51
RefleX Property-test Type Generator
• “Good” Numbers
– 31415 (3 nested structs)
– 32415 (51 nested structs)
– 2626 (12 nested structs)
– 10295 (15 nested structs)
– 21525 (41 nested structs)
– 7937 ( 5 nested structs)
– ...
• “Bad” Numbers
– 2152 (test seg-faults) sizeof(tuple) > 2750 KB!
10/4/2015 © 2015 RTI 52
Github: https://github.com/rticommunity/rticonnextdds-reflex/blob/develop/test/generator
10/4/2015 © 2015 RTI 53
Thank You!

More Related Content

What's hot

Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | EdurekaDocker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | EdurekaEdureka!
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced JavascriptAdieu
 
Comparing Next-Generation Container Image Building Tools
 Comparing Next-Generation Container Image Building Tools Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building ToolsAkihiro Suda
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기Sang Heon Lee
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...Edureka!
 
Effective Java and Kotlin
Effective Java and KotlinEffective Java and Kotlin
Effective Java and Kotlin경주 전
 
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
[NDC17] Kubernetes로 개발서버 간단히 찍어내기[NDC17] Kubernetes로 개발서버 간단히 찍어내기
[NDC17] Kubernetes로 개발서버 간단히 찍어내기SeungYong Oh
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Minh Dao
 
[131]chromium binging 기술을 node.js에 적용해보자
[131]chromium binging 기술을 node.js에 적용해보자[131]chromium binging 기술을 node.js에 적용해보자
[131]chromium binging 기술을 node.js에 적용해보자NAVER D2
 
C#을 사용한 빠른 툴 개발
C#을 사용한 빠른 툴 개발C#을 사용한 빠른 툴 개발
C#을 사용한 빠른 툴 개발흥배 최
 
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍흥배 최
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기Chris Ohk
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applicationsConstantine Slisenka
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Edureka!
 
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features SummaryChris Ohk
 
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)NTT DATA Technology & Innovation
 

What's hot (20)

Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | EdurekaDocker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Angular
AngularAngular
Angular
 
Comparing Next-Generation Container Image Building Tools
 Comparing Next-Generation Container Image Building Tools Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building Tools
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
 
Effective Java and Kotlin
Effective Java and KotlinEffective Java and Kotlin
Effective Java and Kotlin
 
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
[NDC17] Kubernetes로 개발서버 간단히 찍어내기[NDC17] Kubernetes로 개발서버 간단히 찍어내기
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
 
[131]chromium binging 기술을 node.js에 적용해보자
[131]chromium binging 기술을 node.js에 적용해보자[131]chromium binging 기술을 node.js에 적용해보자
[131]chromium binging 기술을 node.js에 적용해보자
 
C#을 사용한 빠른 툴 개발
C#을 사용한 빠른 툴 개발C#을 사용한 빠른 툴 개발
C#을 사용한 빠른 툴 개발
 
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
 
Kotlin
KotlinKotlin
Kotlin
 
Google V8 engine
Google V8 engineGoogle V8 engine
Google V8 engine
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applications
 
UI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QMLUI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QML
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
 
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features Summary
 
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)
My Experiences as a Beginner of OpenJDK Contributor (JCConf Taiwan 2021)
 

Similar to C++ Generators and Property-based Testing

Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Sumant Tambe
 
Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)Sumant Tambe
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTElena Laskavaia
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacriptLei Kang
 
Test strategies for data processing pipelines, v2.0
Test strategies for data processing pipelines, v2.0Test strategies for data processing pipelines, v2.0
Test strategies for data processing pipelines, v2.0Lars Albertsson
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testingEric (Trung Dung) Nguyen
 
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streams
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streamsTech talks annual 2015 kirk pepperdine_ripping apart java 8 streams
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streamsTechTalks
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Ukraine
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-appsVenkata Ramana
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009nkaluva
 
Advanced Analytics using Apache Hive
Advanced Analytics using Apache HiveAdvanced Analytics using Apache Hive
Advanced Analytics using Apache HiveMurtaza Doctor
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedPascal-Louis Perez
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesTao Xie
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 

Similar to C++ Generators and Property-based Testing (20)

Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++
 
Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
 
Golang dot-testing-lite
Golang dot-testing-liteGolang dot-testing-lite
Golang dot-testing-lite
 
Function
FunctionFunction
Function
 
Test strategies for data processing pipelines, v2.0
Test strategies for data processing pipelines, v2.0Test strategies for data processing pipelines, v2.0
Test strategies for data processing pipelines, v2.0
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testing
 
RxJava on Android
RxJava on AndroidRxJava on Android
RxJava on Android
 
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streams
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streamsTech talks annual 2015 kirk pepperdine_ripping apart java 8 streams
Tech talks annual 2015 kirk pepperdine_ripping apart java 8 streams
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
Advanced Analytics using Apache Hive
Advanced Analytics using Apache HiveAdvanced Analytics using Apache Hive
Advanced Analytics using Apache Hive
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Javascript
JavascriptJavascript
Javascript
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 

More from Sumant Tambe

Kafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedKafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedSumant Tambe
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelinesSumant Tambe
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++Sumant Tambe
 
Reactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and RxReactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and RxSumant Tambe
 
RPC over DDS Beta 1
RPC over DDS Beta 1RPC over DDS Beta 1
RPC over DDS Beta 1Sumant Tambe
 
Remote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJSRemote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJSSumant Tambe
 
Reactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/SubscribeReactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/SubscribeSumant Tambe
 
Reactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and RxReactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and RxSumant Tambe
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Sumant Tambe
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDSAn Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDSSumant Tambe
 
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSOverloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSSumant Tambe
 
Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Sumant Tambe
 
Communication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/SubscribeCommunication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/SubscribeSumant Tambe
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 Sumant Tambe
 
Retargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core SystemsRetargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core SystemsSumant Tambe
 
Ph.D. Dissertation
Ph.D. DissertationPh.D. Dissertation
Ph.D. DissertationSumant Tambe
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Sumant Tambe
 

More from Sumant Tambe (19)

Kafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedKafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presented
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelines
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++
 
C++ Coroutines
C++ CoroutinesC++ Coroutines
C++ Coroutines
 
Reactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and RxReactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and Rx
 
RPC over DDS Beta 1
RPC over DDS Beta 1RPC over DDS Beta 1
RPC over DDS Beta 1
 
Remote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJSRemote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJS
 
Reactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/SubscribeReactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/Subscribe
 
Reactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and RxReactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and Rx
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDSAn Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
 
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSOverloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
 
Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++
 
Communication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/SubscribeCommunication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/Subscribe
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
 
Retargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core SystemsRetargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core Systems
 
Ph.D. Dissertation
Ph.D. DissertationPh.D. Dissertation
Ph.D. Dissertation
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)
 

Recently uploaded

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

C++ Generators and Property-based Testing

  • 1. Your systems. Working as one. Sumant Tambe, PhD Principal Research Engineer and Microsoft VC++ MVP Real-Time Innovations, Inc. @sutambe Oct. 3, 2015
  • 2. 10/4/2015 © 2015 RTI 2 LEESA 2008 Rx4DDS 2014 RefleX 2015 Alternative Title
  • 3. 10/4/2015 © 2015 RTI 3 Author Blogger Open-Source LEESA (C++) Rx4DDS (C++11, C#, JavaScript) (C++11)
  • 4. Why should you care? • If you write software for living and if you are serious about any of the following – Bug-free, Expressive code – Productivity • Modularity • Reusability • Extensibility • Maintainability – Performance/latency • Multi-core scalability – and having fun while doing that! 10/4/2015 © 2015 RTI 4
  • 5. Agenda • Property-based Testing • The need for composable generators • Design/Implementation of the generator library • Mathematics of API design – Functor, Monoid, and Monad • Generators at compile-time (type generators) 10/4/2015 © 2015 RTI 5
  • 6. What’s a Property • Reversing a linked-list twice has no effect – reverse(reverse(list)) == list • Compression can make things smaller – compress(input).size <= input.size • Round-trip serialization/deserialization has no effect – deserialize(serialize(input)) == input 10/4/2015 © 2015 RTI 6
  • 7. Testing RefleX • RefleX is short for Reflection for DDS-Xtypes • Serialization and Deserialization – Serializes types and data – Works off of C++ struct/classes directly • C++11/14 • Link 10/4/2015 © 2015 RTI 7
  • 8. RefleX Example 10/4/2015 © 2015 RTI 8 class ShapeType { std::string color_; int x_, y_, shapesize_; public: ShapeType() {} ShapeType(const std::string & color, int x, int y, int shapesize) : color_(color), x_(x), y_(y), shapesize_(shapesize) {} std::string & color(); int & x(); int & y(); int & shapesize(); }; #include "reflex.h" REFLEX_ADAPT_STRUCT( ShapeType, (std::string, color(), KEY) (int, x()) (int, y()) (int, shapesize()))
  • 9. A property-test in RefleX 10/4/2015 © 2015 RTI 9 template <class T> void test_roundtrip_property(const T & in) { reflex::TypeManager<T> tm; reflex::SafeDynamicData<T> safedd = tm.create_dynamicdata(in); reflex::read_dynamicdata(out, safedd); assert(in == out); }
  • 10. Property-based Testing • Complementary to traditional example-based testing • Specify post-conditions that must hold no matter what • Encourages the programmer to think harder about the code • More declarative • Need data generators to produce inputs • Free reproducers! – Good property-based testing frameworks shrink inputs to minimal automatically • Famous: Haskell’s QuickCheck, Scala’s ScalaTest 10/4/2015 © 2015 RTI 10
  • 11. A property-test in RefleX 10/4/2015 © 2015 RTI 11 template <class T> void test_roundtrip_property(const T & in) { reflex::TypeManager<T> tm; reflex::SafeDynamicData<T> safedd = tm.create_dynamicdata(in); reflex::read_dynamicdata(out, safedd); assert(in == out); } What’s the input data? What are the input types?
  • 13. Random Integer Generator 10/4/2015 © 2015 RTI 13 • The simplest data generator size_t seed = time(NULL); srandom(seed); size_t rand() { return random(); } • Alternatively size_t seed = std::chrono::system_clock::now().time_since_epoch().count(); size_t rand() { static std::mt19937 mt(seed); return mt(); }
  • 14. Fundamental Data Generators 10/4/2015 © 2015 RTI 14 • A bool generator bool bool_gen() { return rand() % 2; } • An uppercase character generator char uppercase_gen() // A=65, Z=90 return static_cast<char>(‘A’ + rand() % 26)) }
  • 15. Data Generators 10/4/2015 © 2015 RTI 15 • A range generator – Generates any number in the range int range_gen(int lo, int hi) return lo + rand() % (hi – lo + 1); } • Inconvenient because args must be passed every time Use state!
  • 16. Closure as generator 10/4/2015 © 2015 RTI 16 • A stateful range generator – Generates a random number in the given range auto make_range_gen(int lo, int hi) return [lo, hi]() { return lo + rand() % (hi – lo + 1); } } auto r = range_gen(20, 25); std::cout << r(); // one of 20, 21, 22, 23, 24, 25
  • 17. Closure as generator 10/4/2015 © 2015 RTI 17 • The oneof generator template <class T> auto make_oneof_gen(std::initializer_list<T> list) { return [options = std::vector<T>(list)]() { return *(options.begin() + rand() % options.size()); }; } auto days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” } auto gen = make_oneof_gen(days); std::cout << gen(); // one of Sun, Mon, Tue, Wed, Thu, Fri, Sat
  • 18. 10/4/2015 © 2015 RTI 18 “Closures are poor man's objects; Objects are poor man's closure” -- The venerable master Qc Na Source Google images
  • 19. Closure vs Object • Is function/closure a sufficient abstraction for any generator? []() { return blah; } • Answer depends upon your language – No. In C++ 10/4/2015 © 2015 RTI 19
  • 20. The Generator Class Template 10/4/2015 © 2015 RTI 20 template <class T, class GenFunc> struct Gen : private GenFunc { typedef T value_type; explicit Gen(GenFunc func) : GenFunc(std::move(func)) { } T generate() { return GenFunc::operator()(); } auto map(...) const; auto zip_with(...) const; auto concat(...) const; auto take(...) const;auto concat_map(...) const; auto reduce(...) const; auto where(...) const; auto scan(...) const; };
  • 21. Creating Gen<T> from lambdas template <class GenFunc> auto make_gen_from(GenFunc&& func) { return Gen<decltype(func()), GenFunc> (std::forward<GenFunc>(func)); } template <class Integer> auto make_range_gen(Integer lo, Integer hi) { return make_gen_from([lo, hi]() { return static_cast<Integer>(lo + rand() % (hi - lo)); }); } 10/4/2015 © 2015 RTI 21
  • 22. Composing Generators • Producing complex Generators from one or more simpler Generators 10/4/2015 © 2015 RTI 22 Generator map reduce concat where zip_with concat_map take scan
  • 23. Mapping over a generator 10/4/2015 © 2015 RTI 23 vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” }; auto range_gen = gen::make_range_gen(0,6); // random numbers in range 0..6 auto day_gen = range_gen.map([&](int i) { return days[i]; }); // random days in range “Sun” to “Sat” while(true) std::cout << day_gen.generate(); // random days in range “Sun” to “Sat” Gen<int>  Gen<string> f(int  string) std::function<string(int)>
  • 24. 10/4/2015 © 2015 RTI 24 Generator is a You can over it.
  • 25. Functor Laws • Composition Law gen.map(f).map(g) == gen.map(g o f) 10/4/2015 © 2015 RTI 25 auto DAY_gen = range_gen .map([&](int i) { return days[i]; }); .map([](const string & str) { return std::toupper(str, std::locale()); }); auto DAY_gen = range_gen.map([&](int i) { return std::to_upper(days[i], std::locale()); });
  • 26. Functor Laws • Identity Law gen.map(a -> a) == gen 10/4/2015 © 2015 RTI 26 auto gen2 == gen.map([](auto a) { return a; }); • Both gen and gen2 will generate the same data – Their identities are different but they are still the same
  • 27. Implementing map template <class T> template <class Func> auto Gen<T>::map(Func&& func) const { return make_gen_from( [self = *this, func = std::forward<Func>(func)]() mutable { return func(self.generate()); }); } 10/4/2015 © 2015 RTI 27
  • 28. Concatenating generators 10/4/2015 © 2015 RTI 28 vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” }; auto day_gen = gen::make_inorder_gen(days) // Sun,Mon,...,Sat vector<string> months= { “Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sept”, “Oct”, “Nov”, “Dec” }; auto month_gen = gen::make_inorder_gen(months); auto concat_gen = days_gen.concat(month_gen); for(int i = 0; i < 19; ++i) std::cout << concat_gen.generate(); // Sun,Mon,...,Sat,Jan,Feb,Mar,...,Dec
  • 29. 10/4/2015 © 2015 RTI 29 Generator is a
  • 30. Monoid Laws • Identity Law M o id = id o M = M • Binary operation o = append • Appending to identity (either way) must yield the same generator 10/4/2015 © 2015 RTI 30 auto identity = gen::make_empty_gen<int>(); gen::make_inorder_gen({ 1, 2, 3}).append(identity) == identity.append(gen::make_inorder_gen({ 1, 2, 3});
  • 31. Monoid Laws • Associative Law (f o g) o h = f o (g o h) • Binary operation o = append • Order of operation does not matter. (The order of operands does) – Not to be confused with commutative property where the order of operands does not matter 10/4/2015 © 2015 RTI 31 auto f = gen::make_inorder_gen({ 1, 2}); auto g = gen::make_inorder_gen({ 3, 4}); auto h = gen::make_inorder_gen({ 5, 6}); (f.append(g)).append(h) == f.append(g.append(h));
  • 32. Generator Identity make_empty_gen template <class T> auto make_empty_gen() { return make_gen_from([]() { throw std::out_of_range("empty generator!"); return std::declval<T>(); }); } 10/4/2015 © 2015 RTI 32
  • 33. Zipping Generators 10/4/2015 © 2015 RTI 33 auto x_gen = gen::make_stepper_gen(0,100); auto y_gen = gen::make_stepper_gen(0,200,2); auto point_gen = x_gen.zip_with([](int x, int y) return std::make_pair(x, y); }, y_gen); for(auto _: { 1,2,3 }) std::cout << point_gen.generate(); // {0,0}, {1,2}, {3,4} end
  • 34. Implementing zip_with template <class T> template <class Zipper, class... GenList> auto Gen<T>::zip_with(Zipper&& func, GenList&&... genlist) const { return make_gen_from( [self = *this, genlist..., func = std::forward<Zipper>(func)]() mutable { return func(self.generate(), genlist.generate()...); }); } 10/4/2015 © 2015 RTI 34
  • 35. 10/4/2015 © 2015 RTI 35 Generator is a
  • 36. Dependent Generators (concat_map) auto triangle_gen = gen::make_inorder_gen({1,2,3,4,5,4,3,2,1}) .concat_map([](int i) { std::cout << "n"; return gen::make_stepper_gen(1, i); }); try { while(true) std::cout << triangle_gen.generate(); } catch(std::out_of_range &) { } 10/4/2015 © 2015 RTI 36 1 12 123 1234 12345 1234 123 12 1
  • 37. Monad Laws auto f = [](int i) { return gen::make_stepper_gen(1, i); }; auto g = [](int i) { return gen::make_stepper_gen(i, 1, -1); }; auto M = gen::make_single_gen(300); // left identity is_same(M.concat_map(f), f(300)); // right identity is_same(M.concat_map([](int i) { return gen::make_single_gen(i); }), M); // associativity is_same(M.concat_map(f).concat_map(g), M.concat_map([f,g](int i) mutable { return f(i).concat_map(g); })); 10/4/2015 © 2015 RTI 37
  • 38. 10/4/2015 © 2015 RTI 38 The Mathematics of the Generator API
  • 39. Generators • General design principal – Create a language to solve a problem – API is the language – Reuse parsing/compilation of the host language (duh!) • The “language” of Generators – Primitive values are basic generators – Complex values are composite generators – All APIs result in some generator • Especially, map, zip, reduce, etc. – I.e., generators form an algebra 10/4/2015 © 2015 RTI 39
  • 40. Algebra A first-class abstraction + Compositional* API 10/4/2015 © 2015 RTI 40 *Composition based on mathematical concepts
  • 41. 10/4/2015 © 2015 RTI 41 What Math Concepts? • Algebraic Structures from Category Theory –Monoid –Functor –Monad –Applicative • Where to begin? –Haskell –But innocent should start with Scala perhaps
  • 42. Back to the property-test in RefleX 10/4/2015 © 2015 RTI 42 template <class T> void test_roundtrip_property(const T & in) { reflex::TypeManager<T> tm; reflex::SafeDynamicData<T> safedd = tm.create_dynamicdata(in); reflex::read_dynamicdata(out, safedd); assert(in == out); } What’s the input data? What are the input types?
  • 43. 10/4/2015 © 2015 RTI 43 if we can generate we can generate
  • 44. Random Numbers at Compile-time #include <stdio.h> enum test { Foo = RANDOM }; int main(void) { enum test foo = Foo; printf("foo = %dn", foo); return 0; } 10/4/2015 © 2015 RTI 44 $ gcc –DRANDOM=$RANDOM main.c –o main $ ./main foo = 17695
  • 45. Random Numbers at Compile-time #include <stdio.h> enum test { Foo = RANDOM, Bar = LFSR(Foo) }; int main(void) { enum test foo = Foo; enum test bar = Bar; printf("foo = %d, bar = %dn", foo, bar); } 10/4/2015 © 2015 RTI 45 #define LFSR_bit(prev) (((prev >> 0) ^ (prev >> 2) ^ (prev >> 3) ^ (prev >> 5)) & 1) #define LFSR(prev) ((prev >> 1) | (LFSR_bit(prev) << 15)) $ gcc –DRANDOM=$RANDOM main.c –o main $ ./main foo = 17695, bar = 41615 Could be constexpr
  • 46. Linear Feedback Shift Register (LFSR) • Simple random number generator • 4 bit Fibonacci LFSR • Feedback polynomial = X4 + X3 + 1 • Taps 4 and 3 10/4/2015 © 2015 RTI 46Image source: wikipedia
  • 47. Linear Feedback Shift Register (LFSR) • Live code feedback polynomial (16 bit) – X16 + X14 + X13 + X11 + 1 • Taps: 16, 14, 13, and 11 10/4/2015 © 2015 RTI 47Image source: wikipedia
  • 48. Random Type Generation at Compile-Time template <int I> struct TypeMap; template <> struct TypeMap<0> { typedef int type; }; template <> struct TypeMap<1> { typedef char type; }; template <> struct TypeMap<2> { typedef float type; }; template <> struct TypeMap<3> { typedef double type; }; 10/4/2015 © 2015 RTI 48
  • 49. Random Type Generation at Compile-Time #include <boost/core/demangle.hpp> template <int seed> struct RandomTuple { typedef typename TypeMap<LFSR(seed) % 4>::type First; typedef typename TypeMap<LFSR(LFSR(seed)) % 4>::type Second; typedef typename TypeMap<LFSR(LFSR(LFSR(seed))) % 4>::type Third; typedef std::tuple<First, Second, Third> type; }; 10/4/2015 © 2015 RTI 49 $ g++ –DRANDOM=$RANDOM main.cpp –o main $ ./main foo = 11660, bar = 5830 tuple = std::tuple<float, double, char> int main(void) { auto tuple = RandomTuple<RANDOM>::type(); printf("tuple = %s", boost::core::demangle(typeid(tuple).name()).c_str()); } Live code
  • 50. Tuple Value Generator (zip) template <class... Args> struct GenFactory<std::tuple<Args...>> { static auto make() { return make_zip_gen([](auto&&... args) { return std::make_tuple(std::forward<decltype(args)>(args)...); }, GenFactory<Args>::make()...); } }; int main(void) { auto tuple_gen = GenFactory<RandomTuple<RANDOM>::type>::make(); auto tuple = tuple_gen.generate(); } 10/4/2015 © 2015 RTI 50
  • 51. Type Generators Demystified • Random seed as command line #define • Compile-time random numbers using LFSR • C++ meta-programming for type synthesis • std::string generator for type names and member names • RefleX to map types to typecode and dynamic data • Source: https://github.com/sutambe/generators 10/4/2015 © 2015 RTI 51
  • 52. RefleX Property-test Type Generator • “Good” Numbers – 31415 (3 nested structs) – 32415 (51 nested structs) – 2626 (12 nested structs) – 10295 (15 nested structs) – 21525 (41 nested structs) – 7937 ( 5 nested structs) – ... • “Bad” Numbers – 2152 (test seg-faults) sizeof(tuple) > 2750 KB! 10/4/2015 © 2015 RTI 52 Github: https://github.com/rticommunity/rticonnextdds-reflex/blob/develop/test/generator
  • 53. 10/4/2015 © 2015 RTI 53 Thank You!

Editor's Notes

  1. Incompressible strings of every length exist.