1 #!/usr/bin/env python3 2 # Copyright 2016 Google Inc. All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS-IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 from fruit_test_common import * 17 18 COMMON_DEFINITIONS = ''' 19 #define IN_FRUIT_CPP_FILE 1 20 21 #include "meta/common.h" 22 #include <fruit/impl/meta/metaprogramming.h> 23 #include <fruit/impl/meta/proof_trees.h> 24 #include <fruit/impl/meta/proof_tree_comparison.h> 25 26 #include <vector> 27 28 struct A1 {}; 29 struct B1 {}; 30 struct C1 {}; 31 struct D1 {}; 32 struct X1 {}; 33 struct Y1 {}; 34 35 using A = Type<A1>; 36 using B = Type<B1>; 37 using C = Type<C1>; 38 using D = Type<D1>; 39 using X = Type<X1>; 40 using Y = Type<Y1>; 41 42 using Proof1 = Pair<X, ToSet<A, B>>; 43 using Proof1b = Pair<X, ToSet<B, A>>; 44 using Proof2 = Pair<Y, ToSet<B, C>>; 45 ''' 46 47 def test_IsProofTreeEqualTo(): 48 source = ''' 49 int main() { 50 AssertNotSameProof(Pair<X, ToSet<A>>, Pair<X, ToSet<B>>); 51 AssertNotSameProof(Proof1, Proof2); 52 AssertSameProof(Proof1, Proof1b); 53 } 54 ''' 55 expect_success( 56 COMMON_DEFINITIONS, 57 source, 58 locals()) 59 60 def test_IsForestEqualTo(): 61 source = ''' 62 int main() { 63 AssertSameForest(Vector<>, Vector<>); 64 AssertNotSameForest(Vector<Proof1>, Vector<Proof2>); 65 AssertSameForest(Vector<Proof1, Proof2>, Vector<Proof2, Proof1b>); 66 } 67 ''' 68 expect_success( 69 COMMON_DEFINITIONS, 70 source, 71 locals()) 72 73 if __name__== '__main__': 74 main(__file__) 75