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

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

Issue 23825006: Fix debugger expression evaluation for top-level functions (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
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 Dart_Handle point = Invoke("main"); 1551 Dart_Handle point = Invoke("main");
1552 EXPECT_VALID(point); 1552 EXPECT_VALID(point);
1553 EXPECT(breakpoint_hit == true); 1553 EXPECT(breakpoint_hit == true);
1554 1554
1555 Dart_Handle r = 1555 Dart_Handle r =
1556 Dart_EvaluateExpr(point, NewString("_factor * sqrt(x*x + y*y)")); 1556 Dart_EvaluateExpr(point, NewString("_factor * sqrt(x*x + y*y)"));
1557 EXPECT_VALID(r); 1557 EXPECT_VALID(r);
1558 EXPECT(Dart_IsDouble(r)); 1558 EXPECT(Dart_IsDouble(r));
1559 EXPECT_EQ(50.0, ToDouble(r)); 1559 EXPECT_EQ(50.0, ToDouble(r));
1560 1560
1561 Dart_Handle closure =
1562 Dart_EvaluateExpr(point, NewString("() => _factor * sqrt(x*x + y*y))"));
1563 EXPECT_VALID(closure);
1564 EXPECT(Dart_IsClosure(closure));
1565 r = Dart_InvokeClosure(closure, 0, NULL);
1566 EXPECT_EQ(50.0, ToDouble(r));
1567
1568 r = Dart_EvaluateExpr(point,
1569 NewString("(() => _factor * sqrt(x*x + y*y))()"));
1570 EXPECT_VALID(r);
1571 EXPECT(Dart_IsDouble(r));
1572 EXPECT_EQ(50.0, ToDouble(r));
1573
1561 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length")); 1574 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length"));
1562 EXPECT_VALID(len); 1575 EXPECT_VALID(len);
1563 EXPECT(Dart_IsNumber(len)); 1576 EXPECT(Dart_IsNumber(len));
1564 EXPECT_EQ(3, ToInt64(len)); 1577 EXPECT_EQ(3, ToInt64(len));
1565 1578
1566 Dart_Handle point_class = Dart_GetClass(script_lib, NewString("Point")); 1579 Dart_Handle point_class = Dart_GetClass(script_lib, NewString("Point"));
1567 EXPECT_VALID(point_class); 1580 EXPECT_VALID(point_class);
1568 Dart_Handle elem = Dart_EvaluateExpr(point_class, NewString("m['\"']")); 1581 Dart_Handle elem = Dart_EvaluateExpr(point_class, NewString("m['\"']"));
1569 EXPECT_VALID(elem); 1582 EXPECT_VALID(elem);
1570 EXPECT(Dart_IsString(elem)); 1583 EXPECT(Dart_IsString(elem));
1571 EXPECT_STREQ("quote", ToCString(elem)); 1584 EXPECT_STREQ("quote", ToCString(elem));
1572 1585
1573 elem = Dart_EvaluateExpr(point_class, NewString("m[\"\\t\"]")); 1586 elem = Dart_EvaluateExpr(point_class, NewString("m[\"\\t\"]"));
1574 EXPECT_VALID(elem); 1587 EXPECT_VALID(elem);
1575 EXPECT(Dart_IsString(elem)); 1588 EXPECT(Dart_IsString(elem));
1576 EXPECT_STREQ("tab", ToCString(elem)); 1589 EXPECT_STREQ("tab", ToCString(elem));
1577 1590
1578 res = Dart_EvaluateExpr(script_lib, NewString("l..add(11)..add(-5)")); 1591 res = Dart_EvaluateExpr(script_lib, NewString("l..add(11)..add(-5)"));
1579 EXPECT_VALID(res); 1592 EXPECT_VALID(res);
1580 // List l now has 5 elements. 1593 // List l now has 5 elements.
1581 1594
1582 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1")); 1595 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1"));
1583 EXPECT_VALID(len); 1596 EXPECT_VALID(len);
1584 EXPECT(Dart_IsNumber(len)); 1597 EXPECT(Dart_IsNumber(len));
1585 EXPECT_EQ(6, ToInt64(len)); 1598 EXPECT_EQ(6, ToInt64(len));
1599
1600 closure = Dart_EvaluateExpr(script_lib, NewString("(x) => l.length + x"));
1601 EXPECT_VALID(closure);
1602 EXPECT(Dart_IsClosure(closure));
1603 Dart_Handle args[1] = { Dart_NewInteger(1) };
1604 len = Dart_InvokeClosure(closure, 1, args);
1605 EXPECT_VALID(len);
1606 EXPECT(Dart_IsNumber(len));
1607 EXPECT_EQ(6, ToInt64(len));
1608
1609 len = Dart_EvaluateExpr(script_lib, NewString("((x) => l.length + x)(1)"));
1610 EXPECT_VALID(len);
1611 EXPECT(Dart_IsNumber(len));
1612 EXPECT_EQ(6, ToInt64(len));
1586 } 1613 }
1587 1614
1588 1615
1589 TEST_CASE(Debug_GetSupertype) { 1616 TEST_CASE(Debug_GetSupertype) {
1590 const char* kScriptChars = 1617 const char* kScriptChars =
1591 "class Test {\n" 1618 "class Test {\n"
1592 "}\n" 1619 "}\n"
1593 "class Test1 extends Test {\n" 1620 "class Test1 extends Test {\n"
1594 "}\n" 1621 "}\n"
1595 "class Test2<T> {\n" 1622 "class Test2<T> {\n"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 1752
1726 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); 1753 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj);
1727 Dart_Handle super_type = Dart_GetSupertype(list_type); 1754 Dart_Handle super_type = Dart_GetSupertype(list_type);
1728 EXPECT(!Dart_IsError(super_type)); 1755 EXPECT(!Dart_IsError(super_type));
1729 super_type = Dart_GetSupertype(super_type); 1756 super_type = Dart_GetSupertype(super_type);
1730 EXPECT(!Dart_IsError(super_type)); 1757 EXPECT(!Dart_IsError(super_type));
1731 EXPECT(super_type == Dart_Null()); 1758 EXPECT(super_type == Dart_Null());
1732 } 1759 }
1733 1760
1734 } // namespace dart 1761 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698