Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
bf9830ee
Commit
bf9830ee
authored
10 years ago
by
Brian Terlson
Browse files
Options
Downloads
Plain Diff
Merge pull request #131 from domenic/assert-throws
Add assert.throws
parents
3883a2e9
66a39c04
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/harness/assert.js
+22
-0
22 additions, 0 deletions
test/harness/assert.js
test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A2.2_T1.js
+3
-2
3 additions, 2 deletions
.../suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A2.2_T1.js
with
25 additions
and
2 deletions
test/harness/assert.js
+
22
−
0
View file @
bf9830ee
...
...
@@ -40,3 +40,25 @@ assert.notSameValue = function (actual, unexpected, message) {
}
$ERROR
(
message
);
};
assert
.
throws
=
function
(
expectedErrorConstructor
,
func
)
{
if
(
func
===
undefined
)
{
$ERROR
(
'
assert.throws requires two arguments: the error constructor and a function to run
'
);
return
;
}
try
{
func
();
}
catch
(
thrown
)
{
if
(
typeof
thrown
!==
'
object
'
||
thrown
===
null
)
{
$ERROR
(
'
Thrown value was not an object!
'
);
return
;
}
if
(
thrown
.
constructor
!==
expectedErrorConstructor
)
{
$ERROR
(
'
Expected a
'
+
expectedErrorConstructor
.
name
+
'
but got a
'
+
thrown
.
constructor
.
name
);
}
return
;
}
$ERROR
(
'
Expected a
'
+
expectedErrorConstructor
.
name
+
'
to be thrown but no exception was thrown at all
'
);
};
This diff is collapsed.
Click to expand it.
test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A2.2_T1.js
+
3
−
2
View file @
bf9830ee
...
...
@@ -6,9 +6,10 @@ info: >
Promise throws TypeError when 'this' is constructed but unsettled promise
author: Sam Mikes
description: Promise.call(new Promise()) throws TypeError
negative: TypeError
---*/
var
p
=
new
Promise
(
function
()
{});
Promise
.
call
(
p
,
function
()
{});
assert
.
throws
(
TypeError
,
function
()
{
Promise
.
call
(
p
,
function
()
{});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment