-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add hash to Snak #77
Conversation
does look sane |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
98fb646
to
3e1b06a
Compare
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 :) |
e4abc65
to
0969deb
Compare
npm test? |
|
39a87d7
to
0c6fb17
Compare
The Snak class gains a _hash field and getHash() getter function, and its constructors get a new, optional hash parameter.
0c6fb17
to
d17091d
Compare
Okay, |
There was a problem hiding this 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] ); |
There was a problem hiding this comment.
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]], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
).
There was a problem hiding this comment.
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.
The
Snak
class gains a_hash
field andgetHash()
getter function, and its constructors get a new, optionalhash
parameter.