[M85 Dev][EFL] Fix crashes at webview launch
[platform/framework/web/chromium-efl.git] / base / callback_unittest.nc
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
7
8 #include "base/callback.h"
9
10 namespace base {
11
12 class Parent {
13 };
14
15 class Child : Parent {
16 };
17
18 #if defined(NCTEST_EQUALS_REQUIRES_SAMETYPE)  // [r"fatal error: invalid operands to binary expression \('RepeatingCallback<void \(\)>' and 'RepeatingCallback<int \(\)>'\)"]
19
20 // Attempting to call comparison function on two callbacks of different type.
21 //
22 // This should be a compile time failure because each callback type should be
23 // considered distinct.
24 void WontCompile() {
25   RepeatingCallback<void()> c1;
26   RepeatingCallback<int()> c2;
27   c1 == c2;
28 }
29
30 #elif defined(NCTEST_CONSTRUCTION_FROM_SUBTYPE)  // [r"fatal error: no viable conversion from 'RepeatingCallback<base::Parent \(\)>' to 'RepeatingCallback<base::Child \(\)>'"]
31
32 // Construction of RepeatingCallback<A> from RepeatingCallback<B> if A is
33 // supertype of B.
34 //
35 // While this is technically safe, most people aren't used to it when coding
36 // C++ so if this is happening, it is almost certainly an error.
37 void WontCompile() {
38   RepeatingCallback<Parent()> cb_a;
39   RepeatingCallback<Child()> cb_b = cb_a;
40 }
41
42 #elif defined(NCTEST_ASSIGNMENT_FROM_SUBTYPE)  // [r"fatal error: no viable overloaded '='"]
43
44 // Assignment of RepeatingCallback<A> from RepeatingCallback<B> if A is
45 // supertype of B. See explanation for NCTEST_CONSTRUCTION_FROM_SUBTYPE.
46 void WontCompile() {
47   RepeatingCallback<Parent()> cb_a;
48   RepeatingCallback<Child()> cb_b;
49   cb_a = cb_b;
50 }
51
52 #endif
53
54 }  // namespace base