jenkins-bot has submitted this change and it was merged. Change subject: Implemented ordering of snaks within SnakList ......................................................................
Implemented ordering of snaks within SnakList (bug 52391) Implemented "move" functions in wikibase.SnakList which allow moving snaks within the SnakList while considering the snaks being grouped by property. Change-Id: Ic3e23827144b047038790afddf86996c3efa5c34 --- M lib/resources/wikibase.datamodel/wikibase.SnakList.js M lib/tests/qunit/wikibase.datamodel/Wikibase.SnakList.tests.js M lib/tests/qunit/wikibase.datamodel/Wikibase.claim.tests.js M lib/tests/qunit/wikibase.datamodel/wikibase.Statement.tests.js 4 files changed, 416 insertions(+), 58 deletions(-) Approvals: Tobias Gritschacher: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/resources/wikibase.datamodel/wikibase.SnakList.js b/lib/resources/wikibase.datamodel/wikibase.SnakList.js index c10e37b..9b9caf3 100644 --- a/lib/resources/wikibase.datamodel/wikibase.SnakList.js +++ b/lib/resources/wikibase.datamodel/wikibase.SnakList.js @@ -3,6 +3,7 @@ * @ingroup WikibaseLib * @licence GNU GPL v2+ * @author Daniel Werner < daniel.wer...@wikimedia.de > + * @author H. Snater < mediaw...@snater.com > */ ( function( wb, $ ) { 'use strict'; @@ -151,11 +152,16 @@ ) { return false; } - for( var i in this._snaks ) { - if( !snakList.hasSnak( this._snaks[i] ) ) { + + var otherSnaks = snakList.toArray(); + + // Compare to other snak lists snaks considering order: + for( var i = 0; i < otherSnaks.length; i++ ) { + if( !this._snaks[i].equals( otherSnaks[i] ) ) { return false; } } + return true; }, @@ -209,6 +215,179 @@ }, /** + * Returns a snak's index within the snak list. Returns -1 when the snak could not be found. + * @since 0.4 + * + * @param {wikibase.Snak} snak + * @return {number} + */ + indexOf: function( snak ) { + for( var i = 0; i < this._snaks.length; i++ ) { + if( this._snaks[i].equals( snak ) ) { + return i; + } + } + return -1; + }, + + /** + * Returns the indices of the snak list where a certain snak may be moved to. A snak may be + * moved within its property group. It may also be moved to the slots between property groups + * which involves moving the whole property group the snak belongs to. + * @since 0.4 + * + * @param {wikibase.Snak} snak + * @return {number[]} + */ + getValidMoveIndices: function( snak ) { + var self = this, + indices = [], + isGroupLast = false; + + this.each( function( i, snakListSnak ) { + if( snakListSnak.getPropertyId() === snak.getPropertyId() ) { + // Detect slots within the snak's property group. + if( snakListSnak !== snak ) { + indices.push( i ); + } else { + var nextSnak = self._snaks[i + 1]; + if( nextSnak && nextSnak.getPropertyId() !== snak.getPropertyId() ) { + // Snak is the last of its group. + isGroupLast = true; + } + } + } else { + // Detect slots between property groups. + var previousSnak = self._snaks[i - 1], + isNewPropertyGroup = ( + i !== 0 + && snakListSnak.getPropertyId() !== previousSnak.getPropertyId() + ); + + if( + // Since this snak's property group is not at the top of the snak list, the + // snak (with its group) may always be moved to the top: + i === 0 + // The snak (with its group) may always be moved to between groups except to + // adjacent slots between property groups since the snak's property group would + // in fact not be moved. + || isNewPropertyGroup && previousSnak.getPropertyId() !== snak.getPropertyId() + ) { + indices.push( i ); + } + } + } ); + + // Allow moving to last position if snak is not at the end already: + if( snak !== this._snaks[this._snaks.length - 1] ) { + indices.push( this._snaks.length ); + } + + return indices; + }, + + /** + * Moves a snaklist's snak to a new index. + * @since 0.4 + * + * @param {wikibase.Snak} snak Snak to move within the list. + * @param {number} toIndex + * + * @throws {Error} if snak is not allowed to be moved to toIndex. + */ + move: function( snak, toIndex ) { + if( this.indexOf( snak ) === toIndex ) { + return; + } + + var validIndices = this.getValidMoveIndices( snak ); + + if( $.inArray( toIndex, validIndices ) === -1 ) { + throw new Error( 'Tried to move snak to index ' + toIndex + ' but only the following ' + + 'indices are allowed: ' + validIndices.join( ', ' ) ); + } + + var previousSnak = this._snaks[toIndex -1], + nextSnak = this._snaks[toIndex + 1], + insertBefore = this._snaks[toIndex]; + + if( + previousSnak && previousSnak.getPropertyId() === snak.getPropertyId() + || nextSnak && nextSnak.getPropertyId() === snak.getPropertyId() + ) { + // Moving snak within its property group. + this._snaks.splice( this.indexOf( snak ), 1 ); + + if( insertBefore ) { + this._snaks.splice( toIndex, 0, snak ); + } else { + this._snaks.push( snak ); + } + } else { + // Moving the whole snak group. + var groupedSnaks = []; + + for( var i = 0; i < this._snaks.length; i++ ) { + if( this._snaks[i].getPropertyId() === snak.getPropertyId() ) { + groupedSnaks.push( this._snaks[i] ); + } + } + + for( i = 0; i < groupedSnaks.length; i++ ) { + this._snaks.splice( this.indexOf( groupedSnaks[i] ), 1 ); + if( insertBefore ) { + this._snaks.splice( this.indexOf( insertBefore ), 0, groupedSnaks[i] ); + } else { + this._snaks.push( groupedSnaks[i] ); + } + } + } + + }, + + /** + * Moves a snak towards the top of the snak list by one step. + * @since 0.4 + * + * @param {wikibase.Snak} snak + * @return {number} The snaks new index. + */ + moveUp: function( snak ) { + var index = this.indexOf( snak ), + validIndices = this.getValidMoveIndices( snak ); + + for( var i = validIndices.length - 1; i >= 0; i-- ) { + if( validIndices[i] < index ) { + this.move( snak, validIndices[i] ); + break; + } + } + + return this.indexOf( snak ); + }, + + /** + * Moves a snak towards the bottom of the snak list by one step. + * @since 0.4 + * + * @param {wikibase.Snak} snak + * @return {number} The snak's new index. + */ + moveDown: function( snak ) { + var index = this.indexOf( snak ), + validIndices = this.getValidMoveIndices( snak ); + + for( var i = 0; i < validIndices.length; i++ ) { + if( validIndices[i] > index ) { + this.move( snak, validIndices[i] ); + break; + } + } + + return this.indexOf( snak ); + }, + + /** * Returns a simple JSON structure representing this Snak. The structure will be a map, having * property IDs as keys and an array of the Snak's JSON as values. * diff --git a/lib/tests/qunit/wikibase.datamodel/Wikibase.SnakList.tests.js b/lib/tests/qunit/wikibase.datamodel/Wikibase.SnakList.tests.js index e5e0421..7088f0c 100644 --- a/lib/tests/qunit/wikibase.datamodel/Wikibase.SnakList.tests.js +++ b/lib/tests/qunit/wikibase.datamodel/Wikibase.SnakList.tests.js @@ -22,15 +22,31 @@ [ new wb.PropertyValueSnak( 'p1', new dv.StringValue( 'a' ) ), new wb.PropertyValueSnak( 'p1', new dv.StringValue( 'b' ) ), - new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'a' ) ), - new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'b' ) ), new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'c' ) ), - new wb.PropertyValueSnak( 'p3', new dv.StringValue( 'a' ) ), - new wb.PropertyValueSnak( 'p4', new dv.StringValue( 'a' ) ) + new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'd' ) ), + new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'e' ) ), + new wb.PropertyValueSnak( 'p3', new dv.StringValue( 'f' ) ), + new wb.PropertyValueSnak( 'p4', new dv.StringValue( 'g' ) ) ] ]; var anotherSnak = new wb.PropertySomeValueSnak( 'p1' ), anotherSnak2 = new wb.PropertySomeValueSnak( 'p2' ); + + /** + * Returns the concatenated string values of a snak list's snaks. + * + * @param {wikibase.SnakList} snakList + * @return {string} + */ + function snakOrder( snakList ) { + var snakValues = []; + + snakList.each( function( i, snak ) { + snakValues.push( snak.getValue().getValue() ); + } ); + + return snakValues.join( '' ); + } QUnit.test( 'SnakList constructor', function( assert ) { var snaks = snakSets[0]; @@ -98,7 +114,7 @@ cloneOrder = reorderedClone.getPropertyOrder(); assert.ok( - snakList.equals( reorderedClone ), + !snakList.equals( reorderedClone ), 'Cloned snak list with applying a different property order.' ); @@ -106,7 +122,6 @@ initialOrder[0] === cloneOrder[1] && initialOrder[1] === cloneOrder[0], 'Verified differing property order.' ); - } ); QUnit.test( 'SnakList list operations', function( assert ) { @@ -307,4 +322,168 @@ ); } ); + QUnit.test( 'getValidMoveIndices()', function( assert ) { + var snaks = snakSets[1]; + + /** + * Expected indices where the individual snaks (with or without its groups) may be moved to. + * @type {number[][]} + */ + var validIndices = [ + [1, 5, 6, 7], + [0, 5, 6, 7], + [0, 3, 4, 6, 7], + [0, 2, 4, 6, 7], + [0, 2, 3, 6, 7], + [0, 2, 7], + [0, 2, 5] + ]; + + var snakList = new wb.SnakList( snaks ); + + for( var i = 0; i < validIndices.length; i++ ) { + assert.deepEqual( + snakList.getValidMoveIndices( snaks[i] ), + validIndices[i], + 'Verified indices example snak #' + i + ' may be moved to.' + ); + } + + snakList = new wb.SnakList( + [ new wb.PropertyValueSnak( 'p1', new dv.StringValue( 'a' ) ) ] + ); + + assert.strictEqual( + snakList.getValidMoveIndices( snakList._snaks[0] ).length, + 0, + 'No indices returned when snak list does not contain more than one snak.' + ); + + } ); + + QUnit.test( 'move()', function( assert ) { + var snaks = snakSets[1], + snakList; + + /** + * Array of test case definitions. Test case definition structure: + * [0] => Index of element to move + * [1] => Index where to move element + * [2] => Expected result when concatenating the string values of the snak list's snaks. + * @type {*[][]} + */ + var testCases = [ + [ 0, 1, 'bacdefg' ], + [ 0, 5, 'cdeabfg' ], + [ 0, 6, 'cdefabg' ], + [ 0, 7, 'cdefgab' ], + [ 1, 0, 'bacdefg' ], + [ 1, 5, 'cdeabfg' ], + [ 1, 6, 'cdefabg' ], + [ 1, 7, 'cdefgab' ], + [ 2, 0, 'cdeabfg' ], + [ 2, 3, 'abdcefg' ], + [ 2, 4, 'abdecfg' ], + [ 2, 6, 'abfcdeg' ], + [ 2, 7, 'abfgcde' ], + [ 3, 0, 'cdeabfg' ], + [ 3, 2, 'abdcefg' ], + [ 3, 4, 'abcedfg' ], + [ 3, 6, 'abfcdeg' ], + [ 3, 7, 'abfgcde' ], + [ 4, 0, 'cdeabfg' ], + [ 4, 2, 'abecdfg' ], + [ 4, 3, 'abcedfg' ], + [ 4, 6, 'abfcdeg' ], + [ 4, 7, 'abfgcde' ], + [ 5, 0, 'fabcdeg' ], + [ 5, 2, 'abfcdeg' ], + [ 5, 7, 'abcdegf' ], + [ 6, 0, 'gabcdef' ], + [ 6, 2, 'abgcdef' ], + [ 6, 5, 'abcdegf' ] + ]; + + for( var i = 0; i < testCases.length; i++ ) { + snakList = new wb.SnakList( snaks ); + + snakList.move( snaks[testCases[i][0]], testCases[i][1] ); + + assert.equal( + snakOrder( snakList ), + testCases[i][2], + 'Verified moving a snak with test set #' + i + '.' + ); + } + + snakList = new wb.SnakList( snaks ); + snakList.move( snaks[0], 0 ); + + assert.equal( + snakOrder( snakList ), + 'abcdefg', + 'Nothing changed when trying to move a snak to an index it already has.' + ); + + assert.throws( + function() { + snakList = new wb.SnakList( snaks ); + snakList.move( 0, 4 ); + }, + 'move() throws an error when trying to move a snak to an invalid index.' + ); + } ); + + QUnit.test( 'moveUp() and moveDown()', function( assert ) { + var snaks = snakSets[1], + snakList; + + /** + * Array of test case definitions for moveUp() and moveDown() methods. Test case definition + * structure: + * [0] => Resulting order after moving the element having the same index in the snak list up. + * [1] => Resulting order after moving the element having the same index in the snak list down. + * @type {string[][]} + */ + var testCases = [ + ['abcdefg', 'bacdefg' ], + ['bacdefg', 'cdeabfg' ], + ['cdeabfg', 'abdcefg' ], + ['abdcefg', 'abcedfg' ], + ['abcedfg', 'abfcdeg' ], + ['abfcdeg', 'abcdegf' ], + ['abcdegf', 'abcdefg' ] + ]; + + for( var i = 0; i < testCases.length; i++ ) { + snakList = new wb.SnakList( snaks ); + + assert.strictEqual( + snakList.moveUp( snaks[i] ), + testCases[i][0].indexOf( snaks[i].getValue().getValue() ), + 'moveUp() returns correct new index for test set #' + i + '.' + ); + + assert.equal( + snakOrder( snakList ), + testCases[i][0], + 'Verified moving up a snak with test set #' + i + '.' + ); + + snakList = new wb.SnakList( snaks ); + + assert.strictEqual( + snakList.moveDown( snaks[i] ), + testCases[i][1].indexOf( snaks[i].getValue().getValue() ), + 'moveDown() returns correct new index for test set #' + i + '.' + ); + + assert.equal( + snakOrder( snakList ), + testCases[i][1], + 'Verified moving down a snak with test set #' + i + '.' + ); + } + } ); + }( wikibase, dataValues, jQuery, QUnit ) ); diff --git a/lib/tests/qunit/wikibase.datamodel/Wikibase.claim.tests.js b/lib/tests/qunit/wikibase.datamodel/Wikibase.claim.tests.js index 259525e..1779424 100644 --- a/lib/tests/qunit/wikibase.datamodel/Wikibase.claim.tests.js +++ b/lib/tests/qunit/wikibase.datamodel/Wikibase.claim.tests.js @@ -18,13 +18,13 @@ QUnit.test( 'constructor', function( assert ) { var argumentLists = [ { - mainSnak: new wb.PropertyNoValueSnak( 42 ), + mainSnak: new wb.PropertyNoValueSnak( 'p42' ), qualifiers: new wb.SnakList() }, { - mainSnak: new wb.PropertySomeValueSnak( 9001 ), + mainSnak: new wb.PropertySomeValueSnak( 'p9001' ), qualifiers: new wb.SnakList() }, { - mainSnak: new wb.PropertyValueSnak( 23, new dv.StringValue( '~=[,,_,,]:3' ) ), + mainSnak: new wb.PropertyValueSnak( 'p23', new dv.StringValue( '~=[,,_,,]:3' ) ), qualifiers: new wb.SnakList() } ]; @@ -53,13 +53,13 @@ QUnit.test( 'setMainSnak and getMainSnak', function( assert ) { var claim = new wb.Claim( - new wb.PropertyNoValueSnak( 42 ), + new wb.PropertyNoValueSnak( 'p42' ), new wb.SnakList() ), snaks = [ - new wb.PropertyNoValueSnak( 9001 ), - new wb.PropertySomeValueSnak( 42 ), - new wb.PropertyValueSnak( 23, new dv.StringValue( '~=[,,_,,]:3' ) ) + new wb.PropertyNoValueSnak( 'p9001' ), + new wb.PropertySomeValueSnak( 'p42' ), + new wb.PropertyValueSnak( 'p23', new dv.StringValue( '~=[,,_,,]:3' ) ) ]; $.each( snaks, function( i, snak ) { @@ -79,7 +79,7 @@ } ); QUnit.test( 'toJSON()', function( assert ) { - var claim = new wb.Claim( new wb.PropertyValueSnak( 42, new dv.StringValue( '~=[,,_,,]:3' ) ) ); + var claim = new wb.Claim( new wb.PropertyValueSnak( 'p42', new dv.StringValue( '~=[,,_,,]:3' ) ) ); assert.ok( claim.equals( wb.Claim.newFromJSON( claim.toJSON() ) ), @@ -87,12 +87,12 @@ ); claim = new wb.Claim( - new wb.PropertyNoValueSnak( 42 ), + new wb.PropertyNoValueSnak( 'p42' ), new wb.SnakList( [ - new wb.PropertyNoValueSnak( 9001 ), - new wb.PropertySomeValueSnak( 42 ), - new wb.PropertyValueSnak( 23, new dv.StringValue( '~=[,,_,,]:3' ) ) + new wb.PropertyNoValueSnak( 'p9001' ), + new wb.PropertySomeValueSnak( 'p42' ), + new wb.PropertyValueSnak( 'p23', new dv.StringValue( '~=[,,_,,]:3' ) ) ] ) ); @@ -105,24 +105,24 @@ QUnit.test( 'equals()', function( assert ) { var claims = [ - new wb.Claim( new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) ), + new wb.Claim( new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ), new wb.Claim( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ), + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ), new wb.SnakList( [ - new wb.PropertyValueSnak( 2, new dv.StringValue( 'some string' ) ), - new wb.PropertySomeValueSnak( 9001 ) + new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'some string' ) ), + new wb.PropertySomeValueSnak( 'p9001' ) ] ) ), - new wb.Claim( new wb.PropertyValueSnak( 42, new dv.StringValue( 'other string' ) ) ), - new wb.Claim( new wb.PropertySomeValueSnak( 9001 ) ), + new wb.Claim( new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'other string' ) ) ), + new wb.Claim( new wb.PropertySomeValueSnak( 'p9001' ) ), new wb.Claim( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ), + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ), new wb.SnakList( [ - new wb.PropertyValueSnak( 43, new dv.StringValue( 'some string' ) ), - new wb.PropertySomeValueSnak( 9001 ) + new wb.PropertyValueSnak( 'p43', new dv.StringValue( 'some string' ) ), + new wb.PropertySomeValueSnak( 'p9001' ) ] ) ) @@ -151,9 +151,9 @@ } ); // Compare claim to statement: - var claim = new wb.Claim( new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) ), + var claim = new wb.Claim( new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ), statement = new wb.Statement( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ); assert.ok( diff --git a/lib/tests/qunit/wikibase.datamodel/wikibase.Statement.tests.js b/lib/tests/qunit/wikibase.datamodel/wikibase.Statement.tests.js index e55378e..4356dd8 100644 --- a/lib/tests/qunit/wikibase.datamodel/wikibase.Statement.tests.js +++ b/lib/tests/qunit/wikibase.datamodel/wikibase.Statement.tests.js @@ -15,7 +15,7 @@ QUnit.module( 'wikibase.datamodel.Statement', QUnit.newWbEnvironment() ); QUnit.test( 'toJSON', function( assert ) { - var statement = new wb.Statement( new wb.PropertyNoValueSnak( 42 ) ); + var statement = new wb.Statement( new wb.PropertyNoValueSnak( 'p42' ) ); assert.ok( statement.equals( wb.Claim.newFromJSON( statement.toJSON() ) ), @@ -23,27 +23,27 @@ ); statement = new wb.Statement( - new wb.PropertyValueSnak( 23, new dv.StringValue( '~=[,,_,,]:3' ) ), + new wb.PropertyValueSnak( 'p23', new dv.StringValue( '~=[,,_,,]:3' ) ), new wb.SnakList( [ - new wb.PropertyNoValueSnak( 9001 ), - new wb.PropertySomeValueSnak( 42 ) + new wb.PropertyNoValueSnak( 'p9001' ), + new wb.PropertySomeValueSnak( 'p42' ) ] ), [ new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 3, new dv.StringValue( 'string' ) ), - new wb.PropertySomeValueSnak( 245 ) + new wb.PropertyValueSnak( 'p3', new dv.StringValue( 'string' ) ), + new wb.PropertySomeValueSnak( 'p245' ) ] ) ), new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 856, new dv.StringValue( 'another string' ) ), - new wb.PropertySomeValueSnak( 97 ) + new wb.PropertyValueSnak( 'p856', new dv.StringValue( 'another string' ) ), + new wb.PropertySomeValueSnak( 'p97' ) ] ) ) @@ -60,29 +60,29 @@ QUnit.test( 'equals()', function( assert ) { var statements = [ - new wb.Statement( new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) ), + new wb.Statement( new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ), new wb.Statement( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ), + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ), new wb.SnakList( [ - new wb.PropertyValueSnak( 2, new dv.StringValue( 'some string' ) ), - new wb.PropertySomeValueSnak( 9001 ) + new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'some string' ) ), + new wb.PropertySomeValueSnak( 'p9001' ) ] ), [ new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 3, new dv.StringValue( 'string' ) ), - new wb.PropertySomeValueSnak( 245 ) + new wb.PropertyValueSnak( 'p3', new dv.StringValue( 'string' ) ), + new wb.PropertySomeValueSnak( 'p245' ) ] ) ), new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 856, new dv.StringValue( 'another string' ) ), - new wb.PropertySomeValueSnak( 97 ) + new wb.PropertyValueSnak( 'p856', new dv.StringValue( 'another string' ) ), + new wb.PropertySomeValueSnak( 'p97' ) ] ) ) @@ -91,36 +91,36 @@ ), new wb.Statement( new wb.PropertyValueSnak( 41, new dv.StringValue( 'string' ) ) ), new wb.Statement( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ), + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ), new wb.SnakList( [ new wb.PropertyValueSnak( 2, new dv.StringValue( 'some string' ) ), - new wb.PropertySomeValueSnak( 9001 ) + new wb.PropertySomeValueSnak( 'p9001' ) ] ) ), new wb.Statement( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ), + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ), new wb.SnakList( [ - new wb.PropertyValueSnak( 2, new dv.StringValue( 'some string' ) ), - new wb.PropertySomeValueSnak( 9001 ) + new wb.PropertyValueSnak( 'p2', new dv.StringValue( 'some string' ) ), + new wb.PropertySomeValueSnak( 'p9001' ) ] ), [ new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 3, new dv.StringValue( 'string' ) ), - new wb.PropertySomeValueSnak( 245 ) + new wb.PropertyValueSnak( 'p3', new dv.StringValue( 'string' ) ), + new wb.PropertySomeValueSnak( 'p245' ) ] ) ), new wb.Reference( new wb.SnakList( [ - new wb.PropertyValueSnak( 123, new dv.StringValue( 'another string' ) ), - new wb.PropertySomeValueSnak( 97 ) + new wb.PropertyValueSnak( 'p123', new dv.StringValue( 'another string' ) ), + new wb.PropertySomeValueSnak( 'p97' ) ] ) ) @@ -152,9 +152,9 @@ } ); // Compare claim to statement: - var claim = new wb.Claim( new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) ), + var claim = new wb.Claim( new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ), statement = new wb.Statement( - new wb.PropertyValueSnak( 42, new dv.StringValue( 'string' ) ) + new wb.PropertyValueSnak( 'p42', new dv.StringValue( 'string' ) ) ); assert.ok( -- To view, visit https://gerrit.wikimedia.org/r/80005 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic3e23827144b047038790afddf86996c3efa5c34 Gerrit-PatchSet: 10 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater <henning.sna...@wikimedia.de> Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits