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

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
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 "\n"
3595 "int bad2() {\n"
3596 " int foo = 'string';\n"
3597 " return foo;\n"
3598 "}\n"
3599 "\n"
3600 "int good2() {\n"
3601 " int five = 5;\n"
3602 " return five;"
3603 "}\n"
3604 "\n";
3605 Dart_Handle result;
3606
3607 // Create a test library and Load up a test script in it.
3608 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3609 Dart_IsolateSetCheckedMode(true);
3610
3611 result = Dart_Invoke(lib, NewString("bad1"), 0, NULL);
3612 EXPECT_ERROR(result, "Unhandled exception:\n"
3613 "type 'String' is not a subtype of type 'int' of 'foo'");
3614
3615 result = Dart_Invoke(lib, NewString("good1"), 0, NULL);
3616 EXPECT_VALID(result);
3617
3618 Dart_IsolateSetCheckedMode(false);
regis 2015/02/03 22:23:17 As shown by this test, you cannot flip the isolate
3619
3620 result = Dart_Invoke(lib, NewString("bad2"), 0, NULL);
3621 EXPECT_VALID(result);
3622
3623 result = Dart_Invoke(lib, NewString("good2"), 0, NULL);
3624 EXPECT_VALID(result);
3625 }
3626
3627
3583 TEST_CASE(DebugName) { 3628 TEST_CASE(DebugName) {
3584 Dart_Handle debug_name = Dart_DebugName(); 3629 Dart_Handle debug_name = Dart_DebugName();
3585 EXPECT_VALID(debug_name); 3630 EXPECT_VALID(debug_name);
3586 EXPECT(Dart_IsString(debug_name)); 3631 EXPECT(Dart_IsString(debug_name));
3587 } 3632 }
3588 3633
3589 3634
3590 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) { 3635 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {
3591 } 3636 }
3592 3637
(...skipping 5249 matching lines...) Expand 10 before | Expand all | Expand 10 after
8842 result = Dart_Invoke(lib, 8887 result = Dart_Invoke(lib,
8843 NewString("testView16"), 8888 NewString("testView16"),
8844 1, 8889 1,
8845 dart_args); 8890 dart_args);
8846 EXPECT_VALID(result); 8891 EXPECT_VALID(result);
8847 EXPECT(Dart_IsString(result)); 8892 EXPECT(Dart_IsString(result));
8848 } 8893 }
8849 } 8894 }
8850 8895
8851 } // namespace dart 8896 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698