Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Strapping down of Extend-routines in util.js #3442

Merged
merged 10 commits into from
Sep 16, 2017

Conversation

wimrijnders
Copy link
Contributor

This is internal work, prompted by the investigation in #3408. Submitted here separately in order to keep the PR size(s) down. The reason to do this was to better understand the code, this PR records the results of the investigation for posterity.

Changes:

  • Some refactoring and fixes of the routines in util.js that are used for copying data between objects

  • Added (header) commenting for these routines

  • Added unit tests for these routines.

  • Extra: added unit test for invariability of font properties, because changing these has big consequences for the code in which they are used (paranoia by admission)

Caveat: There still is functionality present which might be considered buggy. Please scan in test/util.test.js for the word 'bug' and give me your opinion on these. Is it something that should be fixed?

This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly).
By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to
squash the bug.

The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object.

Changes:

- Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors.
- Added catch clause in `CanvasRendered._determinePixelRatio()`
- small fix: raised timeout for the network `worldCup2014` unit test
- Small fixes and cleanup in `util.js`
- Removed `util.protoExtend()`, not used anywhere
@wimrijnders wimrijnders changed the title Strapping down of extend-routines in util.js Strapping down of Extend-routines in util.js Sep 13, 2017
Copy link
Contributor

@yotamberk yotamberk left a comment

Choose a reason for hiding this comment

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

I'm good with this PR in general. Tak a look at the 2 minor comments. There is a small conflict to address too.

if (e.message() === 'window is undefined') {
console.warning("'" + e.message() + "' happened again");
var msg = e.message;
//console.warn("Got exception with message: '" + msg + "'");
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, that one. I hope the travis unit test thing is truly dead now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm getting rid of the catch-block, it's not required any more.

checkExtended(a, b);

// NOTE: if allowDeletion === false, null values are copied over!
// This is due to existing logic; it might not be the intention and hence a bug
Copy link
Contributor

Choose a reason for hiding this comment

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

Umm, I don't think it's a good behavior. It does seem like a bug that should be addressed. But on the other-hand, I usually take the approach that if a field is undefined, it should not be assigned a value of undefined whilst null is a legit value in a field and should be passed on in the extend. If that's the behavior of the function, I'm ok with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you; for me the trade-off is between fixing it and keeping it like this so as not to break things elsewhere. I'll have a look if I can get rid of it, or confirm that the current working is good.

@wimrijnders
Copy link
Contributor Author

wimrijnders commented Sep 16, 2017

@yotamberk Please check Caveat comment in first post? There is stuff I encountered during making unit test of which I'm not sure to fix. It's almost legitimate but not consistent.

Copy link
Contributor

@yotamberk yotamberk left a comment

Choose a reason for hiding this comment

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

Ok, I'm fine with letting this be merged and take care of the weird behavior later.

@yotamberk yotamberk merged commit b0481d3 into almende:develop Sep 16, 2017
@wimrijnders wimrijnders deleted the refactorExtendRoutines branch September 18, 2017 05:51
primozs pushed a commit to primozs/vis that referenced this pull request Jan 3, 2019
* The next fix on Travis unit test failure

This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly).
By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to
squash the bug.

The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object.

Changes:

- Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors.
- Added catch clause in `CanvasRendered._determinePixelRatio()`
- small fix: raised timeout for the network `worldCup2014` unit test

* Preliminary refactoring in utils.js

* Added unit tests for extend routines, commenting and small fixes

* More unit tests for extend routines

* - Completed unit tests for extend routines in
- Small fixes and cleanup in `util.js`
- Removed `util.protoExtend()`, not used anywhere

* Added unit tests for known font options
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants