Chromium Code Reviews| 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. | |
|
hausner
2014/07/10 22:57:26
Maybe add a sentence why that is significant?
rmacnak
2014/07/10 23:17:37
Added.
| |
| 2009 const char* kScriptChars = | |
| 2010 "import 'dart:math'; \n" | |
| 2011 "class Point { \n" | |
| 2012 " var x, y; \n" | |
| 2013 " Point(this.x, this.y); \n" | |
| 2014 " get r => sqrt(x*x + y*y); \n" | |
| 2015 "} \n"; | |
|
hausner
2014/07/10 22:57:26
Nit: alignment.
| |
| 2016 LoadScript(kScriptChars); | |
| 2017 Dart_FinalizeLoading(); | |
|
hausner
2014/07/10 22:57:26
Why not moving the FinalizeLoading call into the h
rmacnak
2014/07/10 23:17:37
Some tests fail, mostly related to snapshots.
| |
| 2018 | |
| 2019 Dart_SetExceptionThrownHandler(&EvaluateInActivationOfEvaluateHandler); | |
| 2020 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); | |
| 2021 breakpoint_hit_counter = 0; | |
| 2022 | |
| 2023 Dart_Handle result = Dart_EvaluateExpr(script_lib, NewString( | |
| 2024 "() { var p = new Point(3, 4); throw p; } ())")); | |
| 2025 EXPECT(Dart_IsError(result)); | |
| 2026 EXPECT_EQ(1, breakpoint_hit_counter); | |
| 2027 } | |
| 2028 | |
| 2029 | |
| 1993 TEST_CASE(Debug_GetClosureInfo) { | 2030 TEST_CASE(Debug_GetClosureInfo) { |
| 1994 const char* kScriptChars = | 2031 const char* kScriptChars = |
| 1995 "void foo() { return 43; } \n" | 2032 "void foo() { return 43; } \n" |
| 1996 " \n" | 2033 " \n" |
| 1997 "main() { \n" | 2034 "main() { \n" |
| 1998 " return foo; \n" | 2035 " return foo; \n" |
| 1999 "} \n"; | 2036 "} \n"; |
| 2000 | 2037 |
| 2001 LoadScript(kScriptChars); | 2038 LoadScript(kScriptChars); |
| 2002 Dart_Handle clo = Invoke("main"); | 2039 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," | 2258 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," |
| 2222 " null, 4, 13, 3, 14, 10," | 2259 " null, 4, 13, 3, 14, 10," |
| 2223 " null, 5, 17, 5, 18, 9, 19, 12," | 2260 " null, 5, 17, 5, 18, 9, 19, 12," |
| 2224 " null, 6, 21, 1," | 2261 " null, 6, 21, 1," |
| 2225 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," | 2262 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," |
| 2226 " null, 9, 29, 1]", | 2263 " null, 9, 29, 1]", |
| 2227 tokens_cstr); | 2264 tokens_cstr); |
| 2228 } | 2265 } |
| 2229 | 2266 |
| 2230 } // namespace dart | 2267 } // namespace dart |
| OLD | NEW |