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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 NewString("(() => _factor * sqrt(x*x + y*y))()")); | 1576 NewString("(() => _factor * sqrt(x*x + y*y))()")); |
1577 EXPECT_VALID(r); | 1577 EXPECT_VALID(r); |
1578 EXPECT(Dart_IsDouble(r)); | 1578 EXPECT(Dart_IsDouble(r)); |
1579 EXPECT_EQ(50.0, ToDouble(r)); | 1579 EXPECT_EQ(50.0, ToDouble(r)); |
1580 | 1580 |
1581 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length")); | 1581 Dart_Handle len = Dart_EvaluateExpr(point, NewString("l.length")); |
1582 EXPECT_VALID(len); | 1582 EXPECT_VALID(len); |
1583 EXPECT(Dart_IsNumber(len)); | 1583 EXPECT(Dart_IsNumber(len)); |
1584 EXPECT_EQ(3, ToInt64(len)); | 1584 EXPECT_EQ(3, ToInt64(len)); |
1585 | 1585 |
1586 Dart_Handle point_class = Dart_GetClass(script_lib, NewString("Point")); | 1586 Dart_Handle point_type = |
1587 EXPECT_VALID(point_class); | 1587 Dart_GetType(script_lib, NewString("Point"), 0, NULL); |
1588 Dart_Handle elem = Dart_EvaluateExpr(point_class, NewString("m['\"']")); | 1588 EXPECT_VALID(point_type); |
| 1589 EXPECT(Dart_IsType(point_type)); |
| 1590 Dart_Handle elem = Dart_EvaluateExpr(point_type, NewString("m['\"']")); |
1589 EXPECT_VALID(elem); | 1591 EXPECT_VALID(elem); |
1590 EXPECT(Dart_IsString(elem)); | 1592 EXPECT(Dart_IsString(elem)); |
1591 EXPECT_STREQ("quote", ToCString(elem)); | 1593 EXPECT_STREQ("quote", ToCString(elem)); |
1592 | 1594 |
1593 elem = Dart_EvaluateExpr(point_class, NewString("m[\"\\t\"]")); | 1595 elem = Dart_EvaluateExpr(point_type, NewString("m[\"\\t\"]")); |
1594 EXPECT_VALID(elem); | 1596 EXPECT_VALID(elem); |
1595 EXPECT(Dart_IsString(elem)); | 1597 EXPECT(Dart_IsString(elem)); |
1596 EXPECT_STREQ("tab", ToCString(elem)); | 1598 EXPECT_STREQ("tab", ToCString(elem)); |
1597 | 1599 |
1598 res = Dart_EvaluateExpr(script_lib, NewString("l..add(11)..add(-5)")); | 1600 res = Dart_EvaluateExpr(script_lib, NewString("l..add(11)..add(-5)")); |
1599 EXPECT_VALID(res); | 1601 EXPECT_VALID(res); |
1600 // List l now has 5 elements. | 1602 // List l now has 5 elements. |
1601 | 1603 |
1602 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1")); | 1604 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1")); |
1603 EXPECT_VALID(len); | 1605 EXPECT_VALID(len); |
1604 EXPECT(Dart_IsNumber(len)); | 1606 EXPECT(Dart_IsNumber(len)); |
1605 EXPECT_EQ(6, ToInt64(len)); | 1607 EXPECT_EQ(6, ToInt64(len)); |
1606 | 1608 |
1607 closure = Dart_EvaluateExpr(script_lib, NewString("(x) => l.length + x")); | 1609 closure = Dart_EvaluateExpr(script_lib, NewString("(x) => l.length + x")); |
1608 EXPECT_VALID(closure); | 1610 EXPECT_VALID(closure); |
1609 EXPECT(Dart_IsClosure(closure)); | 1611 EXPECT(Dart_IsClosure(closure)); |
1610 Dart_Handle args[1] = { Dart_NewInteger(1) }; | 1612 Dart_Handle args[1] = { Dart_NewInteger(1) }; |
1611 len = Dart_InvokeClosure(closure, 1, args); | 1613 len = Dart_InvokeClosure(closure, 1, args); |
1612 EXPECT_VALID(len); | 1614 EXPECT_VALID(len); |
1613 EXPECT(Dart_IsNumber(len)); | 1615 EXPECT(Dart_IsNumber(len)); |
1614 EXPECT_EQ(6, ToInt64(len)); | 1616 EXPECT_EQ(6, ToInt64(len)); |
1615 | 1617 |
1616 len = Dart_EvaluateExpr(script_lib, NewString("((x) => l.length + x)(1)")); | 1618 len = Dart_EvaluateExpr(script_lib, NewString("((x) => l.length + x)(1)")); |
1617 EXPECT_VALID(len); | 1619 EXPECT_VALID(len); |
1618 EXPECT(Dart_IsNumber(len)); | 1620 EXPECT(Dart_IsNumber(len)); |
1619 EXPECT_EQ(6, ToInt64(len)); | 1621 EXPECT_EQ(6, ToInt64(len)); |
| 1622 |
| 1623 Dart_Handle error = |
| 1624 Dart_EvaluateExpr(script_lib, NewString("new NonexistingType()")); |
| 1625 EXPECT(Dart_IsError(error)); |
1620 } | 1626 } |
1621 | 1627 |
1622 | 1628 |
1623 TEST_CASE(Debug_GetSupertype) { | 1629 TEST_CASE(Debug_GetSupertype) { |
1624 const char* kScriptChars = | 1630 const char* kScriptChars = |
1625 "class Test {\n" | 1631 "class Test {\n" |
1626 "}\n" | 1632 "}\n" |
1627 "class Test1 extends Test {\n" | 1633 "class Test1 extends Test {\n" |
1628 "}\n" | 1634 "}\n" |
1629 "class Test2<T> {\n" | 1635 "class Test2<T> {\n" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 | 1765 |
1760 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); | 1766 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); |
1761 Dart_Handle super_type = Dart_GetSupertype(list_type); | 1767 Dart_Handle super_type = Dart_GetSupertype(list_type); |
1762 EXPECT(!Dart_IsError(super_type)); | 1768 EXPECT(!Dart_IsError(super_type)); |
1763 super_type = Dart_GetSupertype(super_type); | 1769 super_type = Dart_GetSupertype(super_type); |
1764 EXPECT(!Dart_IsError(super_type)); | 1770 EXPECT(!Dart_IsError(super_type)); |
1765 EXPECT(super_type == Dart_Null()); | 1771 EXPECT(super_type == Dart_Null()); |
1766 } | 1772 } |
1767 | 1773 |
1768 } // namespace dart | 1774 } // namespace dart |
OLD | NEW |