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

Unified Diff: runtime/vm/compiler_test.cc

Issue 23067006: Evaluate expression in context of an object (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler_test.cc
===================================================================
--- runtime/vm/compiler_test.cc (revision 26326)
+++ runtime/vm/compiler_test.cc (working copy)
@@ -5,6 +5,7 @@
#include "platform/assert.h"
#include "vm/class_finalizer.h"
#include "vm/compiler.h"
+#include "vm/dart_api_impl.h"
#include "vm/object.h"
#include "vm/symbols.h"
#include "vm/unit_test.h"
@@ -63,4 +64,34 @@
EXPECT(function_moo.HasCode());
}
+
+TEST_CASE(EvalExpression) {
+ const char* kScriptChars =
+ "int ten = 2 * 5; \n"
+ "get dot => '.'; \n"
+ "class A { \n"
+ " var apa = 'Herr Nilsson'; \n"
+ " calc(x) => '${x*ten}'; \n"
+ "} \n"
+ "makeObj() => new A(); \n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ Dart_Handle obj_handle =
+ Dart_Invoke(lib, Dart_NewStringFromCString("makeObj"), 0, NULL);
+ EXPECT(!Dart_IsNull(obj_handle));
+ EXPECT(!Dart_IsError(obj_handle));
+ const Object& obj = Object::Handle(Api::UnwrapHandle(obj_handle));
+ EXPECT(!obj.IsNull());
+ EXPECT(obj.IsInstance());
+
+ String& expr_text = String::Handle();
+ expr_text = String::New("apa + ' ${calc(10)}' + dot");
+ Object& val = Object::Handle();
+ val = Instance::Cast(obj).Evaluate(expr_text);
+ EXPECT(!val.IsNull());
+ EXPECT(!val.IsError());
+ EXPECT(val.IsString());
+ EXPECT_STREQ("Herr Nilsson 100.", val.ToCString());
+}
+
} // namespace dart
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698