8c64adf13e
-- Terminology change: invalid handles are now called error handles. Unhandled exceptions used to be a kind of valid handle. Now they are a kind of error handle. For the Dart_Invoke* functions, this means that the standard error-checking blob drops from two tests to one test and is harder to mess up. Many other Dart api functions (Dart_ToString, for example) previously dealt with unhandled exceptions by turning them into terse error messages. Now these functions preserve information about the exceptions and generate better error messages. Changed Dart_HandleMessage to return success/failure. It seemed to fit. -- Details: Dart_IsValid becomes Dart_IsError (negated sense). Dart_GetError now knows how to print a stack trace semi-nicely. Dart_ExceptionOccurred -> Dart_IsUnhandledException. Renamed ApiFailure class to ApiError to fit better. ApiError now has a "data" pointer that points to either an error message string or to an unhandled exception object. Documentation changes aplenty. Review URL: http://codereview.chromium.org//8501034 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1470 260f80e4-7a28-3924-810f-c04153c831b5
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/assert.h"
|
|
#include "vm/globals.h"
|
|
#include "vm/isolate.h"
|
|
#include "vm/unit_test.h"
|
|
|
|
namespace dart {
|
|
|
|
UNIT_TEST_CASE(IsolateCurrent) {
|
|
Isolate* isolate = Isolate::Init();
|
|
EXPECT_EQ(isolate, Isolate::Current());
|
|
isolate->Shutdown();
|
|
EXPECT_EQ(reinterpret_cast<Isolate*>(NULL), Isolate::Current());
|
|
delete isolate;
|
|
}
|
|
|
|
|
|
#if defined(TARGET_ARCH_IA32) // only ia32 can run dart execution tests.
|
|
// Unit test case to verify error during isolate spawning (application classes
|
|
// not loaded into the isolate).
|
|
TEST_CASE(IsolateSpawn) {
|
|
const char* kScriptChars =
|
|
"class SpawnNewIsolate extends Isolate {\n"
|
|
" SpawnNewIsolate() : super() { }\n"
|
|
" void main() {\n"
|
|
" }\n"
|
|
" static int testMain() {\n"
|
|
" try {\n"
|
|
" new SpawnNewIsolate().spawn().then(function(SendPort port) {\n"
|
|
" });\n"
|
|
" } catch (var e) {\n"
|
|
" throw;\n"
|
|
" }\n"
|
|
" return 0;\n"
|
|
" }\n"
|
|
"}\n";
|
|
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
|
Dart_Handle result = Dart_InvokeStatic(lib,
|
|
Dart_NewString("SpawnNewIsolate"),
|
|
Dart_NewString("testMain"),
|
|
0,
|
|
NULL);
|
|
EXPECT(Dart_IsError(result));
|
|
EXPECT(Dart_ErrorHasException(result));
|
|
Dart_Handle exception_result = Dart_ErrorGetException(result);
|
|
EXPECT_VALID(exception_result);
|
|
}
|
|
#endif // TARGET_ARCH_IA32.
|
|
|
|
} // namespace dart
|