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

Add hash to Snak #77

Merged
merged 1 commit into from
Aug 31, 2017
Merged

Add hash to Snak #77

merged 1 commit into from
Aug 31, 2017

Conversation

lucaswerkmeister
Copy link
Member

The Snak class gains a _hash field and getHash() getter function, and its constructors get a new, optional hash parameter.

@manicki
Copy link
Member

manicki commented Aug 31, 2017

does look sane

Copy link
Contributor

@thiemowmde thiemowmde left a comment

Choose a reason for hiding this comment

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

I think at least a very basic test should be added. Preferably three tests for the three subclasses. Otherwise this change is fine. Good job with the "can only be computed server-side" documentation!

README.md Outdated
### 3.1.0 (dev)

* Added `hash` parameters to the `Snak` class constructors
and a `getHash()` function to the `Snak` class.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should mention the actual classes that got a new constructor parameter. For two of them the new parameter is the 2nd, for one it's the 3rd.

@lucaswerkmeister
Copy link
Member Author

I’ve added some tests, but I couldn’t figure out how to run the tests locally, so I’ll wait for CI to tell me if they pass :)

@manicki
Copy link
Member

manicki commented Aug 31, 2017

I’ve added some tests, but I couldn’t figure out how to run the tests locally,

npm test?

@lucaswerkmeister
Copy link
Member Author

npm test fails immediately because there’s no eslint in my $PATH. grunt test can run eslint but fails on stylelint. npm run run-tests fails because there’s no karma in my path.

The Snak class gains a _hash field and getHash() getter function, and
its constructors get a new, optional hash parameter.
@lucaswerkmeister
Copy link
Member Author

Okay, npm has a special path so npm install was all I needed, thanks Leszek :) test passes now.

Copy link
Contributor

@thiemowmde thiemowmde left a comment

Choose a reason for hiding this comment

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

Cool, thanks! I will wait a little bit for other opinions, and will merge this tomorrow or on Monday.

@@ -21,11 +21,11 @@ var testSets = [
* @return {wikibase.datamodel.Snak}
*/
function constructSnak( SnakConstructor, params ) {
return new SnakConstructor( params[0], params[1] );
return new SnakConstructor( params[0], params[1], params[2] );
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty awkward, because this code always passes three constructor arguments, even if there are only two for two of the subclasses. But the test setup was like this before and the change made in this patch doesn't make it worse.

[wb.datamodel.PropertySomeValueSnak, ['P1']],
[wb.datamodel.PropertyValueSnak, ['P1', new dv.StringValue( 'test' )]],
[wb.datamodel.PropertyValueSnak, ['P2', new dv.StringValue( 'test' )]]
[wb.datamodel.PropertyNoValueSnak, ['P1', undefined]],
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the two "undefined" can be omitted, but it doesn't hurt to have them.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, they’re necessary because the expected hash is the last array element (array[array.length-1]).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thanks! I see it now.

@manicki manicki merged commit 7cf362c into master Aug 31, 2017
@manicki manicki deleted the snakHash branch August 31, 2017 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants