| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/class_finalizer.h" | 6 #include "vm/class_finalizer.h" |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 Object& val = Object::Handle(); | 92 Object& val = Object::Handle(); |
| 93 val = Instance::Cast(obj).Evaluate(expr_text, | 93 val = Instance::Cast(obj).Evaluate(expr_text, |
| 94 Array::empty_array(), | 94 Array::empty_array(), |
| 95 Array::empty_array()); | 95 Array::empty_array()); |
| 96 EXPECT(!val.IsNull()); | 96 EXPECT(!val.IsNull()); |
| 97 EXPECT(!val.IsError()); | 97 EXPECT(!val.IsError()); |
| 98 EXPECT(val.IsString()); | 98 EXPECT(val.IsString()); |
| 99 EXPECT_STREQ("Herr Nilsson 100.", val.ToCString()); | 99 EXPECT_STREQ("Herr Nilsson 100.", val.ToCString()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 |
| 103 TEST_CASE(EvalExpressionWithLazyCompile) { |
| 104 Library& lib = Library::Handle(Library::CoreLibrary()); |
| 105 |
| 106 const String& expression = String::Handle(String::New( |
| 107 "(){ return (){ return (){ return 3 + 4; }(); }(); }()")); |
| 108 Object& val = Object::Handle(); |
| 109 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); |
| 110 |
| 111 EXPECT(!val.IsNull()); |
| 112 EXPECT(!val.IsError()); |
| 113 EXPECT(val.IsInteger()); |
| 114 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
| 115 } |
| 116 |
| 117 |
| 118 TEST_CASE(EvalExpressionExhaustCIDs) { |
| 119 Library& lib = Library::Handle(Library::CoreLibrary()); |
| 120 |
| 121 const String& expression = String::Handle(String::New("3 + 4")); |
| 122 Object& val = Object::Handle(); |
| 123 |
| 124 const intptr_t classTableSize = 1 << RawObject::kClassIdTagSize; |
| 125 for (intptr_t i = 0; i < classTableSize; i++) { |
| 126 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); |
| 127 } |
| 128 |
| 129 EXPECT(!val.IsNull()); |
| 130 EXPECT(!val.IsError()); |
| 131 EXPECT(val.IsInteger()); |
| 132 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
| 133 } |
| 134 |
| 102 } // namespace dart | 135 } // namespace dart |
| OLD | NEW |