Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2025, 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.

/// @assertion Exception for when the promise is rejected with a `null` or
/// `undefined` value.
///
/// @description Checks that this exception occurs when the promise is rejected
/// with a `null` value.
/// @author sgrekhov22@gmail.com

import 'dart:async';
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import '../../../Utils/expect.dart';
import '../js_utils.dart';

main() {
eval(r'''
globalThis.promise = new Promise(function(resolve, reject) {
reject(null);
});
''');
JSPromise promise = globalContext["promise"] as JSPromise;
asyncStart();
promise.toDart.then((v) {
Expect.fail("NullRejectionException expected");
}).onError((e, st) {
Expect.isTrue(e is NullRejectionException);
Expect.isFalse((e as NullRejectionException).isUndefined);
asyncEnd();
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2025, 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.

/// @assertion Exception for when the promise is rejected with a `null` or
/// `undefined` value.
///
/// @description Checks that this exception occurs when the promise is rejected
/// with an `undefined` value.
/// @author sgrekhov22@gmail.com

import 'dart:async';
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import '../../../Utils/expect.dart';
import '../js_utils.dart';

main() {
eval(r'''
globalThis.promise = new Promise(function(resolve, reject) {
reject(undefined);
});
''');
JSPromise promise = globalContext["promise"] as JSPromise;
asyncStart();
promise.toDart.then((v) {
Expect.fail("NullRejectionException expected");
}).onError((e, st) {
Expect.isTrue(e is NullRejectionException);
Expect.isTrue((e as NullRejectionException).isUndefined);
asyncEnd();
});
}