[DAGCombiner] Expand combining of FP logical ops to sign-setting FP ops
[llvm-core.git] / unittests / ADT / FunctionRefTest.cpp
blobb7ef7d79e5f99f8636ec60d55da8d0dcc0fbeddd
1 //===- llvm/unittest/ADT/MakeUniqueTest.cpp - make_unique unit tests ------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/STLExtras.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
15 namespace {
17 // Ensure that there is a default constructor and we can test for a null
18 // function_ref.
19 TEST(FunctionRefTest, Null) {
20 function_ref<int()> F;
21 EXPECT_FALSE(F);
23 auto L = [] { return 1; };
24 F = L;
25 EXPECT_TRUE(F);
27 F = {};
28 EXPECT_FALSE(F);
31 // Ensure that copies of a function_ref copy the underlying state rather than
32 // causing one function_ref to chain to the next.
33 TEST(FunctionRefTest, Copy) {
34 auto A = [] { return 1; };
35 auto B = [] { return 2; };
36 function_ref<int()> X = A;
37 function_ref<int()> Y = X;
38 X = B;
39 EXPECT_EQ(1, Y());