blob: 075d9a070df72afe69c6c865f388375c87343771 [file] [log] [blame]
David Blaikie45dc4802014-11-12 02:06:08 +00001//===- 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//===----------------------------------------------------------------------===//
9
10#include "llvm/ADT/STLExtras.h"
11#include "gtest/gtest.h"
12
13using namespace llvm;
14
15namespace {
16
17// Ensure that copies of a function_ref copy the underlying state rather than
18// causing one function_ref to chain to the next.
19TEST(FunctionRefTest, Copy) {
20 auto A = [] { return 1; };
21 auto B = [] { return 2; };
22 function_ref<int()> X = A;
23 function_ref<int()> Y = X;
24 X = B;
25 EXPECT_EQ(1, Y());
26}
27
28}