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
5be3a801
Commit
5be3a801
authored
9 years ago
by
Leonardo Balter
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for Subclassing the built-in Date Objects
parent
f5b5ad47
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/language/subclassing/Date/regular-subclassing.js
+37
-0
37 additions, 0 deletions
test/language/subclassing/Date/regular-subclassing.js
test/language/subclassing/Date/super-must-be-called.js
+35
-0
35 additions, 0 deletions
test/language/subclassing/Date/super-must-be-called.js
with
72 additions
and
0 deletions
test/language/subclassing/Date/regular-subclassing.js
0 → 100644
+
37
−
0
View file @
5be3a801
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.3.2
description: Subclassing the String object
info: >
20.3.2 The Date Constructor
...
The Date constructor is a single function whose behaviour is overloaded based
upon the number and types of its arguments.
The Date constructor is designed to be subclassable. It may be used as the
value of an extends clause of a class definition. Subclass constructors that
intend to inherit the specified Date behaviour must include a super call to
the Date constructor to create and initialize the subclass instance with a
[[DateValue]] internal slot.
---*/
class
D
extends
Date
{}
var
d1
=
new
D
(
1859
,
'
10
'
,
24
);
assert
.
sameValue
(
d1
.
getUTCFullYear
(),
1859
);
assert
.
sameValue
(
d1
.
getUTCMonth
(),
10
);
assert
.
sameValue
(
d1
.
getUTCDate
(),
24
);
var
d2
=
new
D
(
-
3474558000000
);
assert
.
sameValue
(
d2
.
getUTCFullYear
(),
1859
);
assert
.
sameValue
(
d2
.
getUTCMonth
(),
10
);
assert
.
sameValue
(
d2
.
getUTCDate
(),
24
);
var
d3
=
new
D
();
var
d4
=
new
Date
();
assert
.
sameValue
(
d3
.
getUTCFullYear
(),
d4
.
getUTCFullYear
());
assert
.
sameValue
(
d3
.
getUTCMonth
(),
d4
.
getUTCMonth
());
assert
.
sameValue
(
d3
.
getUTCDate
(),
d4
.
getUTCDate
());
This diff is collapsed.
Click to expand it.
test/language/subclassing/Date/super-must-be-called.js
0 → 100644
+
35
−
0
View file @
5be3a801
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.3.2
description: Super need to be called to initialize internals
info: >
20.3.2 The Date Constructor
...
The Date constructor is a single function whose behaviour is overloaded based
upon the number and types of its arguments.
The Date constructor is designed to be subclassable. It may be used as the
value of an extends clause of a class definition. Subclass constructors that
intend to inherit the specified Date behaviour must include a super call to
the Date constructor to create and initialize the subclass instance with a
[[DateValue]] internal slot.
---*/
class
D
extends
Date
{
constructor
()
{}
}
assert
.
throws
(
ReferenceError
,
function
()
{
new
D
();
});
class
D2
extends
Date
{
constructor
()
{
super
();
}
}
new
D2
();
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