diff options
author | Adrian Kummerlaender | 2015-02-12 14:32:33 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-02-12 14:32:33 +0100 |
commit | 246cb31c1e20cdcc21a6a607de4b0095c71315d6 (patch) | |
tree | 0301c23d9c09b0a578413019a2d27f75cf69a374 /test.cc | |
parent | 4bb200de716891ed6c9fc182311c02685c8bdfd4 (diff) | |
download | TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.gz TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.bz2 TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.lz TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.xz TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.tar.zst TypeAsValue-246cb31c1e20cdcc21a6a607de4b0095c71315d6.zip |
Implemented `Cond` conditional
* returns the `CDR` of the first true `CAR` in a given list of pairs
* reimplemented `Apply` base class selection in terms of `Cond`
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -233,6 +233,31 @@ static_assert( "(if #f 1 2) != 2" ); +static_assert( + std::is_same< + tav::Int<2>, + tav::Cond< + tav::Pair<tav::IsEqualValue<tav::Int<1>, tav::Int<2>>, tav::Int<1>>, + tav::Pair<tav::IsEqualValue<tav::Int<2>, tav::Int<2>>, tav::Int<2>>, + tav::Pair<tav::IsEqualValue<tav::Int<3>, tav::Int<2>>, tav::Int<3>> + >::type + >::value, + "(cond ((= 1 2) 1) ((= 2 2) 2) ((= 3 2) 3)) != 2" +); + +static_assert( + std::is_same< + tav::Int<-1>, + tav::Cond< + tav::Pair<tav::IsEqualValue<tav::Int<1>, tav::Int<2>>, tav::Int< 1>>, + tav::Pair<tav::IsEqualValue<tav::Int<2>, tav::Int<3>>, tav::Int< 2>>, + tav::Pair<tav::IsEqualValue<tav::Int<3>, tav::Int<4>>, tav::Int< 3>>, + tav::Pair<tav::Boolean<true>, tav::Int<-1>> + >::type + >::value, + "(cond ((= 1 2) 1) ((= 2 3) 2) ((= 3 4) 3) (else -1)) != -1" +); + // cons static_assert( @@ -1020,3 +1045,15 @@ static_assert( >::value, "(map (lambda (x) (+ x 10)) (list 0 2 4)) != (list 10 12 14)" ); + +static_assert( + std::is_same< + tav::Int<42>, + tav::Apply< + tav::Multiply, + tav::Int<21>, + tav::Int<2> + >::type::type + >::value, + "(* 21 2) != 42" +); |