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

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

Issue 10829332: - Split functionality of adding implicit constructors and checking (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/parser.cc » ('J')
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_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 5462 matching lines...) Expand 10 before | Expand all | Expand 10 after
5473 EXPECT_VALID(Dart_StringToCString(result, &result_cstr)); 5473 EXPECT_VALID(Dart_StringToCString(result, &result_cstr));
5474 EXPECT_STREQ("bar", result_cstr); 5474 EXPECT_STREQ("bar", result_cstr);
5475 } 5475 }
5476 5476
5477 5477
5478 TEST_CASE(ParsePatchLibrary) { 5478 TEST_CASE(ParsePatchLibrary) {
5479 const char* kLibraryChars = 5479 const char* kLibraryChars =
5480 "#library('patched_library');\n" 5480 "#library('patched_library');\n"
5481 "class A {\n" 5481 "class A {\n"
5482 " var _f;\n" 5482 " var _f;\n"
5483 " callFunc(x, y) => x(y);\n"
5483 " external method(var value);\n" 5484 " external method(var value);\n"
5484 " get field() => _field;\n" 5485 " get field() => _field;\n"
5485 "}\n" 5486 "}\n"
5486 "external int unpatched();\n" 5487 "external int unpatched();\n"
5487 "external int topLevel(var value);\n" 5488 "external int topLevel(var value);\n"
5488 "external int get topLevelGetter();\n" 5489 "external int get topLevelGetter();\n"
5489 "external void set topLevelSetter(int value);\n"; 5490 "external void set topLevelSetter(int value);\n";
5490 5491
5491 const char* kPatchChars = 5492 const char* kPatchChars =
5492 "patch class A {\n" 5493 "patch class A {\n"
5493 " var _g;\n" 5494 " var _g;\n"
5494 " get _field() => _g;\n" 5495 " get _field() => _g;\n"
5495 " patch method(var value) {\n" 5496 " patch method(var value) {\n"
5497 " int closeYourEyes(var eggs) { return eggs * -1; }\n"
5498 " value = callFunc(closeYourEyes, value);\n"
5496 " _g = value * 5;\n" 5499 " _g = value * 5;\n"
5497 " }\n" 5500 " }\n"
5498 "}\n" 5501 "}\n"
5499 "var _topLevelValue = -1;\n" 5502 "var _topLevelValue = -1;\n"
5500 "patch int topLevel(var value) => value * value;\n" 5503 "patch int topLevel(var value) => value * value;\n"
5501 "patch int set topLevelSetter(value) { _topLevelValue = value; }\n" 5504 "patch int set topLevelSetter(value) { _topLevelValue = value; }\n"
5502 "patch int get topLevelGetter() => 2 * _topLevelValue;\n" 5505 "patch int get topLevelGetter() => 2 * _topLevelValue;\n"
5503 // Allow top level methods named patch. 5506 // Allow top level methods named patch.
5504 "patch(x) => x*3;\n"; 5507 "patch(x) => x*3;\n";
5505 5508
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5566 EXPECT_VALID(result); 5569 EXPECT_VALID(result);
5567 EXPECT(Dart_IsInteger(result)); 5570 EXPECT(Dart_IsInteger(result));
5568 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); 5571 EXPECT_VALID(Dart_IntegerToInt64(result, &value));
5569 EXPECT_EQ(21, value); 5572 EXPECT_EQ(21, value);
5570 5573
5571 value = 0; 5574 value = 0;
5572 result = Dart_Invoke(test_script, Dart_NewString("m4"), 0, NULL); 5575 result = Dart_Invoke(test_script, Dart_NewString("m4"), 0, NULL);
5573 EXPECT_VALID(result); 5576 EXPECT_VALID(result);
5574 EXPECT(Dart_IsInteger(result)); 5577 EXPECT(Dart_IsInteger(result));
5575 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); 5578 EXPECT_VALID(Dart_IntegerToInt64(result, &value));
5576 EXPECT_EQ(25, value); 5579 EXPECT_EQ(-25, value);
5577 } 5580 }
5578 5581
5579 5582
5580 static void MyNativeFunction1(Dart_NativeArguments args) { 5583 static void MyNativeFunction1(Dart_NativeArguments args) {
5581 Dart_EnterScope(); 5584 Dart_EnterScope();
5582 Dart_SetReturnValue(args, Dart_NewInteger(654321)); 5585 Dart_SetReturnValue(args, Dart_NewInteger(654321));
5583 Dart_ExitScope(); 5586 Dart_ExitScope();
5584 } 5587 }
5585 5588
5586 5589
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
6583 EXPECT(Dart_IsString(str)); 6586 EXPECT(Dart_IsString(str));
6584 len = -1; 6587 len = -1;
6585 EXPECT_VALID(Dart_StringLength(str, &len)); 6588 EXPECT_VALID(Dart_StringLength(str, &len));
6586 EXPECT_EQ(0, len); 6589 EXPECT_EQ(0, len);
6587 } 6590 }
6588 6591
6589 6592
6590 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 6593 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
6591 6594
6592 } // namespace dart 6595 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698