| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 EXPECT_VALID(len); | 1983 EXPECT_VALID(len); |
| 1984 EXPECT(Dart_IsNumber(len)); | 1984 EXPECT(Dart_IsNumber(len)); |
| 1985 EXPECT_EQ(6, ToInt64(len)); | 1985 EXPECT_EQ(6, ToInt64(len)); |
| 1986 | 1986 |
| 1987 Dart_Handle error = | 1987 Dart_Handle error = |
| 1988 Dart_EvaluateExpr(script_lib, NewString("new NonexistingType()")); | 1988 Dart_EvaluateExpr(script_lib, NewString("new NonexistingType()")); |
| 1989 EXPECT(Dart_IsError(error)); | 1989 EXPECT(Dart_IsError(error)); |
| 1990 } | 1990 } |
| 1991 | 1991 |
| 1992 | 1992 |
| 1993 static void EvaluateInActivationOfEvaluateHandler(Dart_IsolateId isolate_id, |
| 1994 Dart_Handle exception_object, |
| 1995 Dart_StackTrace trace) { |
| 1996 breakpoint_hit_counter++; |
| 1997 Dart_ActivationFrame top_frame = 0; |
| 1998 Dart_Handle result = Dart_GetActivationFrame(trace, 0, &top_frame); |
| 1999 EXPECT_VALID(result); |
| 2000 |
| 2001 result = Dart_ActivationFrameEvaluate(top_frame, NewString("p.r")); |
| 2002 EXPECT_VALID(result); |
| 2003 EXPECT_EQ(5.0, ToDouble(result)); |
| 2004 } |
| 2005 |
| 2006 |
| 2007 TEST_CASE(Debug_EvaluateInActivationOfEvaluate) { |
| 2008 // This library deliberately declares no top-level variables or methods. This |
| 2009 // exercises a path in eval where a library may have no top-level anonymous |
| 2010 // classes. |
| 2011 const char* kScriptChars = |
| 2012 "import 'dart:math'; \n" |
| 2013 "class Point { \n" |
| 2014 " var x, y; \n" |
| 2015 " Point(this.x, this.y); \n" |
| 2016 " get r => sqrt(x*x + y*y); \n" |
| 2017 "} \n"; |
| 2018 LoadScript(kScriptChars); |
| 2019 Dart_FinalizeLoading(); |
| 2020 |
| 2021 Dart_SetExceptionThrownHandler(&EvaluateInActivationOfEvaluateHandler); |
| 2022 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); |
| 2023 breakpoint_hit_counter = 0; |
| 2024 |
| 2025 Dart_Handle result = Dart_EvaluateExpr(script_lib, NewString( |
| 2026 "() { var p = new Point(3, 4); throw p; } ())")); |
| 2027 EXPECT(Dart_IsError(result)); |
| 2028 EXPECT_EQ(1, breakpoint_hit_counter); |
| 2029 } |
| 2030 |
| 2031 |
| 1993 TEST_CASE(Debug_GetClosureInfo) { | 2032 TEST_CASE(Debug_GetClosureInfo) { |
| 1994 const char* kScriptChars = | 2033 const char* kScriptChars = |
| 1995 "void foo() { return 43; } \n" | 2034 "void foo() { return 43; } \n" |
| 1996 " \n" | 2035 " \n" |
| 1997 "main() { \n" | 2036 "main() { \n" |
| 1998 " return foo; \n" | 2037 " return foo; \n" |
| 1999 "} \n"; | 2038 "} \n"; |
| 2000 | 2039 |
| 2001 LoadScript(kScriptChars); | 2040 LoadScript(kScriptChars); |
| 2002 Dart_Handle clo = Invoke("main"); | 2041 Dart_Handle clo = Invoke("main"); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," | 2260 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," |
| 2222 " null, 4, 13, 3, 14, 10," | 2261 " null, 4, 13, 3, 14, 10," |
| 2223 " null, 5, 17, 5, 18, 9, 19, 12," | 2262 " null, 5, 17, 5, 18, 9, 19, 12," |
| 2224 " null, 6, 21, 1," | 2263 " null, 6, 21, 1," |
| 2225 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," | 2264 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," |
| 2226 " null, 9, 29, 1]", | 2265 " null, 9, 29, 1]", |
| 2227 tokens_cstr); | 2266 tokens_cstr); |
| 2228 } | 2267 } |
| 2229 | 2268 |
| 2230 } // namespace dart | 2269 } // namespace dart |
| OLD | NEW |