Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: runtime/vm/debugger_api_impl_test.cc

Issue 23439002: JSON string decoding for VM debugger (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/thread.h" 8 #include "vm/thread.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 breakpoint_hit_counter++; 1519 breakpoint_hit_counter++;
1520 } 1520 }
1521 1521
1522 1522
1523 TEST_CASE(Debug_EvaluateExpr) { 1523 TEST_CASE(Debug_EvaluateExpr) {
1524 const char* kScriptChars = 1524 const char* kScriptChars =
1525 "import 'dart:math'; \n" 1525 "import 'dart:math'; \n"
1526 "main() { \n" 1526 "main() { \n"
1527 " var p = new Point(3, 4); \n" 1527 " var p = new Point(3, 4); \n"
1528 " l = [1, 2, 3]; /*BP*/ \n" 1528 " l = [1, 2, 3]; /*BP*/ \n"
1529 " m = {'\"': 'quote' , \n"
1530 " \"\t\": 'tab' }; \n"
1529 " return p; \n" 1531 " return p; \n"
1530 "} \n" 1532 "} \n"
1531 "var _factor = 2; \n" 1533 "var _factor = 2; \n"
1532 "var l; \n" 1534 "var l; \n"
1535 "var m; \n"
1533 "class Point { \n" 1536 "class Point { \n"
1534 " var x, y; \n" 1537 " var x, y; \n"
1535 " Point(this.x, this.y); \n" 1538 " Point(this.x, this.y); \n"
1536 "} \n"; 1539 "} \n";
1537 1540
1538 LoadScript(kScriptChars); 1541 LoadScript(kScriptChars);
1539 Dart_SetPausedEventHandler(&TestEvaluateHandler); 1542 Dart_SetPausedEventHandler(&TestEvaluateHandler);
1540 1543
1541 1544
1542 Dart_Handle script_url = NewString(TestCase::url()); 1545 Dart_Handle script_url = NewString(TestCase::url());
1543 intptr_t line_no = 4; 1546 intptr_t line_no = 4;
1544 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no); 1547 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no);
1545 EXPECT_VALID(res); 1548 EXPECT_VALID(res);
1546 1549
1547 breakpoint_hit = false; 1550 breakpoint_hit = false;
1548 Dart_Handle point = Invoke("main"); 1551 Dart_Handle point = Invoke("main");
1549 EXPECT_VALID(point); 1552 EXPECT_VALID(point);
1550 EXPECT(breakpoint_hit == true); 1553 EXPECT(breakpoint_hit == true);
1551 1554
1552 Dart_Handle r = 1555 Dart_Handle r =
1553 Dart_EvaluateExpr(point, NewString("_factor * sqrt(x*x + y*y)")); 1556 Dart_EvaluateExpr(point, NewString("_factor * sqrt(x*x + y*y)"));
1554 EXPECT_VALID(r); 1557 EXPECT_VALID(r);
1555 EXPECT(Dart_IsDouble(r)); 1558 EXPECT(Dart_IsDouble(r));
1556 EXPECT_EQ(50.0, ToDouble(r)); 1559 EXPECT_EQ(50.0, ToDouble(r));
1557 1560
1558 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length")); 1561 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length"));
1559 EXPECT_VALID(len); 1562 EXPECT_VALID(len);
1560 EXPECT(Dart_IsNumber(len)); 1563 EXPECT(Dart_IsNumber(len));
1561 EXPECT_EQ(3, ToInt64(len)); 1564 EXPECT_EQ(3, ToInt64(len));
1565
1566 Dart_Handle point_class = Dart_GetClass(script_lib, NewString("Point"));
1567 EXPECT_VALID(point_class);
1568 Dart_Handle elem = Dart_EvaluateExpr(point_class, NewString("m['\"']"));
1569 EXPECT_VALID(elem);
1570 EXPECT(Dart_IsString(elem));
1571 EXPECT_STREQ("quote", ToCString(elem));
1572
1573 elem = Dart_EvaluateExpr(point_class, NewString("m[\"\\t\"]"));
1574 EXPECT_VALID(elem);
1575 EXPECT(Dart_IsString(elem));
1576 EXPECT_STREQ("tab", ToCString(elem));
1562 } 1577 }
1563 1578
1564 1579
1565 TEST_CASE(Debug_GetSupertype) { 1580 TEST_CASE(Debug_GetSupertype) {
1566 const char* kScriptChars = 1581 const char* kScriptChars =
1567 "class Test {\n" 1582 "class Test {\n"
1568 "}\n" 1583 "}\n"
1569 "class Test1 extends Test {\n" 1584 "class Test1 extends Test {\n"
1570 "}\n" 1585 "}\n"
1571 "class Test2<T> {\n" 1586 "class Test2<T> {\n"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 1716
1702 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); 1717 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj);
1703 Dart_Handle super_type = Dart_GetSupertype(list_type); 1718 Dart_Handle super_type = Dart_GetSupertype(list_type);
1704 EXPECT(!Dart_IsError(super_type)); 1719 EXPECT(!Dart_IsError(super_type));
1705 super_type = Dart_GetSupertype(super_type); 1720 super_type = Dart_GetSupertype(super_type);
1706 EXPECT(!Dart_IsError(super_type)); 1721 EXPECT(!Dart_IsError(super_type));
1707 EXPECT(super_type == Dart_Null()); 1722 EXPECT(super_type == Dart_Null());
1708 } 1723 }
1709 1724
1710 } // namespace dart 1725 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698