1 // Purpose:
2 // Check that \DexExpectWatchType applies penalties when expected
3 // types are not found and unexpected types are.
4 //
5 // UNSUPPORTED: system-darwin
6 //
7 //
8 // NOTE: This test passes but not in the expected way on Windows.
9 // TODO: Reduce this test's coverage and be more specific about
10 // expected behaviour.
11 //
12 // RUN: not %dexter_regression_test -- %s | FileCheck %s
13 // CHECK: expect_watch_type.cpp:
14
15 template<class T>
16 class Doubled {
17 public:
Doubled(const T & to_double)18 Doubled(const T & to_double)
19 : m_member(to_double * 2) {}
20
GetVal()21 T GetVal() {
22 T to_return = m_member; // DexLabel('gv_start')
23 return to_return; // DexLabel('gv_end')
24 }
25
static_doubler(const T & to_double)26 static T static_doubler(const T & to_double) {
27 T result = 0; // DexLabel('sd_start')
28 result = to_double * 2;
29 return result; // DexLabel('sd_end')
30 }
31
32 private:
33 T m_member;
34 };
35
main()36 int main() {
37 auto myInt = Doubled<int>(5); // DexLabel('main_start')
38 auto myDouble = Doubled<double>(5.5);
39 auto staticallyDoubledInt = Doubled<int>::static_doubler(5);
40 auto staticallyDoubledDouble = Doubled<double>::static_doubler(5.5);
41 return int(double(myInt.GetVal())
42 + double(staticallyDoubledInt)
43 + myDouble.GetVal()
44 + staticallyDoubledDouble); // DexLabel('main_end')
45 }
46
47
48 // DexExpectWatchType('m_member', 'int', 'double', from_line=ref('gv_start'), to_line=ref('gv_end'))
49
50 // THIS COMMAND should create a penalty for a missing type 'const double' and unexpected type 'const double &'
51 // DexExpectWatchType('to_double', 'const double', 'const int &', from_line=ref('sd_start'), to_line=ref('sd_end'))
52
53 // DexExpectWatchType('myInt', 'Doubled<int>', from_line=ref('main_start'), to_line=ref('main_end'))
54 // DexExpectWatchType('myDouble', 'Doubled<double>', from_line=ref('main_start'), to_line=ref('main_end'))
55 // DexExpectWatchType('staticallyDoubledInt', 'int', from_line=ref('main_start'), to_line=ref('main_end'))
56 // DexExpectWatchType('staticallyDoubledDouble', 'double', from_line=ref('main_start'), to_line=ref('main_end'))
57
58