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

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

Issue 883263004: Allows turning on checked mode on a per-isolate basis (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_builder.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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 3562 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 Dart_CreateIsolate(NULL, NULL, bin::snapshot_buffer, 3573 Dart_CreateIsolate(NULL, NULL, bin::snapshot_buffer,
3574 reinterpret_cast<void*>(mydata), 3574 reinterpret_cast<void*>(mydata),
3575 &err); 3575 &err);
3576 EXPECT(isolate != NULL); 3576 EXPECT(isolate != NULL);
3577 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); 3577 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData()));
3578 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); 3578 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate)));
3579 Dart_ShutdownIsolate(); 3579 Dart_ShutdownIsolate();
3580 } 3580 }
3581 3581
3582 3582
3583 TEST_CASE(IsolateSetCheckedMode) {
3584 const char* kScriptChars =
3585 "int bad1() {\n"
3586 " int foo = 'string';\n"
3587 " return foo;\n"
3588 "}\n"
3589 "\n"
3590 "int good1() {\n"
3591 " int five = 5;\n"
3592 " return five;"
3593 "}\n";
3594 Dart_Handle result;
3595
3596 // Create a test library and Load up a test script in it.
3597 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3598 result = Dart_IsolateSetStrictCompilation(true);
3599 EXPECT_VALID(result);
3600
3601 result = Dart_Invoke(lib, NewString("bad1"), 0, NULL);
3602 EXPECT_ERROR(result, "Unhandled exception:\n"
3603 "type 'String' is not a subtype of type 'int' of 'foo'");
3604
3605 result = Dart_Invoke(lib, NewString("good1"), 0, NULL);
3606 EXPECT_VALID(result);
3607
3608 result = Dart_IsolateSetStrictCompilation(false);
3609 EXPECT_ERROR(result, "Dart_IsolateSetStrictCompilation expects that the "
3610 "isolate has not yet compiled code.");
3611 }
3612
3613
3583 TEST_CASE(DebugName) { 3614 TEST_CASE(DebugName) {
3584 Dart_Handle debug_name = Dart_DebugName(); 3615 Dart_Handle debug_name = Dart_DebugName();
3585 EXPECT_VALID(debug_name); 3616 EXPECT_VALID(debug_name);
3586 EXPECT(Dart_IsString(debug_name)); 3617 EXPECT(Dart_IsString(debug_name));
3587 } 3618 }
3588 3619
3589 3620
3590 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) { 3621 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {
3591 } 3622 }
3592 3623
(...skipping 5249 matching lines...) Expand 10 before | Expand all | Expand 10 after
8842 result = Dart_Invoke(lib, 8873 result = Dart_Invoke(lib,
8843 NewString("testView16"), 8874 NewString("testView16"),
8844 1, 8875 1,
8845 dart_args); 8876 dart_args);
8846 EXPECT_VALID(result); 8877 EXPECT_VALID(result);
8847 EXPECT(Dart_IsString(result)); 8878 EXPECT(Dart_IsString(result));
8848 } 8879 }
8849 } 8880 }
8850 8881
8851 } // namespace dart 8882 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698