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 16from absl.testing import parameterized 17from fruit_test_common import * 18 19COMMON_DEFINITIONS = ''' 20 #define IN_FRUIT_CPP_FILE 1 21 22 #include "meta/common.h" 23 #include <fruit/impl/meta/metaprogramming.h> 24 #include <fruit/impl/meta/proof_trees.h> 25 #include <fruit/impl/meta/proof_tree_comparison.h> 26 27 #include <vector> 28 29 struct A1 {}; 30 struct B1 {}; 31 struct C1 {}; 32 struct D1 {}; 33 struct X1 {}; 34 struct Y1 {}; 35 36 using A = Type<A1>; 37 using B = Type<B1>; 38 using C = Type<C1>; 39 using D = Type<D1>; 40 using X = Type<X1>; 41 using Y = Type<Y1>; 42 43 using Proof1 = Pair<X, ToSet<A, B>>; 44 using Proof1b = Pair<X, ToSet<B, A>>; 45 using Proof2 = Pair<Y, ToSet<B, C>>; 46 ''' 47 48class TestProofTrees(parameterized.TestCase): 49 def test_IsProofTreeEqualTo(self): 50 source = ''' 51 int main() { 52 AssertNotSameProof(Pair<X, ToSet<A>>, Pair<X, ToSet<B>>); 53 AssertNotSameProof(Proof1, Proof2); 54 AssertSameProof(Proof1, Proof1b); 55 } 56 ''' 57 expect_success( 58 COMMON_DEFINITIONS, 59 source, 60 locals()) 61 62 def test_IsForestEqualTo(self): 63 source = ''' 64 int main() { 65 AssertSameForest(Vector<>, Vector<>); 66 AssertNotSameForest(Vector<Proof1>, Vector<Proof2>); 67 AssertSameForest(Vector<Proof1, Proof2>, Vector<Proof2, Proof1b>); 68 } 69 ''' 70 expect_success( 71 COMMON_DEFINITIONS, 72 source, 73 locals()) 74 75if __name__ == '__main__': 76 absltest.main() 77