Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: move JSDate "ToString" logic to JSDate class #257

Closed
wants to merge 3 commits into from

Conversation

Drieger
Copy link
Contributor

@Drieger Drieger commented Jan 16, 2019

Move logic that was representing a JSDate object
to a string from the Printer::Stringfy method to
the JSDate class, implementing "ToString" method.

return pre + s + ">";
}

double d = static_cast<double>(val.raw());
Copy link
Contributor Author

@Drieger Drieger Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanlucas do you remember why this last part, casting to double, was added? I couldn't find any test case where I could reach it. It was originally introduced in https://github.com/nodejs/llnode/pull/3/files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not off the top of my head, sorry!

@mmarchini mmarchini added the author ready PRs that have at least one approvals, no pending requests for changes, and a CI started. label Jan 25, 2019
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a nit

src/llv8-inl.h Outdated
@@ -279,6 +279,18 @@ ACCESSOR(JSRegExp, GetSource, js_regexp()->kSourceOffset, String)

ACCESSOR(JSDate, GetValue, js_date()->kValueOffset, Value)

bool JSDate::IsSmi(Error& err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two helpers seem unnecessary if the call site need to grab the values out either ways?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having IsTYPE methods instead of duplicating the tests everywhere. If V8 changes how we check for a type we only need to make changes to one place. But I'd rather have all IsTYPE methods in the Value class, so it resembles the V8 API (https://github.com/nodejs/llnode/pull/247/files#diff-6863f2f9f81092029c00ed6e07b78700R60).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But looking again those two don't add much value, since they're just calling .Check...

We might want to settle on style here (TYPE.Check() vs. Value.IsTYPE()), but we don't have to decide in this PR.

Copy link
Contributor

@mmarchini mmarchini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but ToString should be moved to the Printer class.

@mmarchini
Copy link
Contributor

Ignore my previous comment, I've mistaken ToString with the old Inspect methods. This looks fine.

Drieger and others added 3 commits February 26, 2019 16:49
Move logic that was representing a JSDate object
to a string from the Printer::Stringfy method to
the JSDate class, implementing "ToString" method.
@codecov-io
Copy link

codecov-io commented Feb 26, 2019

Codecov Report

Merging #257 into master will increase coverage by 0.46%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #257      +/-   ##
==========================================
+ Coverage   79.96%   80.42%   +0.46%     
==========================================
  Files          34       34              
  Lines        4292     4292              
==========================================
+ Hits         3432     3452      +20     
+ Misses        860      840      -20
Impacted Files Coverage Δ
src/llv8.h 97.56% <ø> (+2.43%) ⬆️
test/plugin/inspect-test.js 92.49% <ø> (ø) ⬆️
src/printer.cc 84.5% <100%> (+2.44%) ⬆️
src/llv8.cc 76.11% <80%> (+0.06%) ⬆️
src/llv8-inl.h 93.54% <0%> (+0.26%) ⬆️
src/llv8-constants.cc 86.62% <0%> (+1%) ⬆️
src/llv8-constants.h 98.43% <0%> (+1.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea06ef5...3912ebe. Read the comment docs.

@mmarchini
Copy link
Contributor

Daniel is on vacation, so I added a commit to address the nit.

mmarchini pushed a commit that referenced this pull request Mar 5, 2019
Move logic that was representing a JSDate object
to a string from the Printer::Stringfy method to
the JSDate class, implementing "ToString" method.

PR-URL: #257
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
@mmarchini
Copy link
Contributor

Landed in ecfbdca

@mmarchini mmarchini closed this Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approvals, no pending requests for changes, and a CI started.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants