diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
commit | 29b5ab554790bb57337a3b6ab9dcd963cf69d22e (patch) | |
tree | be1456d2bc6c1fb078695fad7bc8f6b212062d3c /tests/resources/userdiff | |
parent | Initial commit. (diff) | |
download | libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.tar.xz libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.zip |
Adding upstream version 1.7.2+ds.upstream/1.7.2+ds
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/resources/userdiff')
33 files changed, 769 insertions, 0 deletions
diff --git a/tests/resources/userdiff/.gitted/HEAD b/tests/resources/userdiff/.gitted/HEAD new file mode 100644 index 0000000..cb089cd --- /dev/null +++ b/tests/resources/userdiff/.gitted/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests/resources/userdiff/.gitted/config b/tests/resources/userdiff/.gitted/config new file mode 100644 index 0000000..6c9406b --- /dev/null +++ b/tests/resources/userdiff/.gitted/config @@ -0,0 +1,7 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true diff --git a/tests/resources/userdiff/.gitted/description b/tests/resources/userdiff/.gitted/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/tests/resources/userdiff/.gitted/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests/resources/userdiff/.gitted/index b/tests/resources/userdiff/.gitted/index Binary files differnew file mode 100644 index 0000000..548dc7b --- /dev/null +++ b/tests/resources/userdiff/.gitted/index diff --git a/tests/resources/userdiff/.gitted/info/refs b/tests/resources/userdiff/.gitted/info/refs new file mode 100644 index 0000000..b074314 --- /dev/null +++ b/tests/resources/userdiff/.gitted/info/refs @@ -0,0 +1 @@ +60e3f7b244a5305e2c9fa4ef0e897f3b14f3b8dd refs/heads/master diff --git a/tests/resources/userdiff/.gitted/objects/09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 b/tests/resources/userdiff/.gitted/objects/09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 Binary files differnew file mode 100644 index 0000000..cbaf4c1 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 diff --git a/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc b/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc Binary files differnew file mode 100644 index 0000000..fa149da --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc diff --git a/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd b/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd Binary files differnew file mode 100644 index 0000000..7483736 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd diff --git a/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b b/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b Binary files differnew file mode 100644 index 0000000..29b72fb --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b diff --git a/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 b/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 Binary files differnew file mode 100644 index 0000000..5fc8391 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 diff --git a/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 b/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 Binary files differnew file mode 100644 index 0000000..debf7e4 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 diff --git a/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 b/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 Binary files differnew file mode 100644 index 0000000..e8b884c --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 diff --git a/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd b/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd Binary files differnew file mode 100644 index 0000000..cfbef99 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd diff --git a/tests/resources/userdiff/.gitted/objects/info/packs b/tests/resources/userdiff/.gitted/objects/info/packs new file mode 100644 index 0000000..0c5fc2a --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/info/packs @@ -0,0 +1,2 @@ +P pack-1652578900ac63564f2a24b9714529821276ceb9.pack + diff --git a/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx Binary files differnew file mode 100644 index 0000000..6f4381c --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx diff --git a/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack Binary files differnew file mode 100644 index 0000000..39bd1d8 --- /dev/null +++ b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack diff --git a/tests/resources/userdiff/.gitted/packed-refs b/tests/resources/userdiff/.gitted/packed-refs new file mode 100644 index 0000000..802f67c --- /dev/null +++ b/tests/resources/userdiff/.gitted/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled +60e3f7b244a5305e2c9fa4ef0e897f3b14f3b8dd refs/heads/master diff --git a/tests/resources/userdiff/.gitted/refs/dummy-marker.txt b/tests/resources/userdiff/.gitted/refs/dummy-marker.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/resources/userdiff/.gitted/refs/dummy-marker.txt diff --git a/tests/resources/userdiff/after/file.html b/tests/resources/userdiff/after/file.html new file mode 100644 index 0000000..2320e2f --- /dev/null +++ b/tests/resources/userdiff/after/file.html @@ -0,0 +1,41 @@ +<html> +<body> + <h1 id="first section"> + <ol> + <li>item 1.1</li> + <li>item 1.2 changed</li> + <li>item 1.3 changed</li> + <li>item 1.4</li> + <li>item 1.5</li> + <li>item 1.6</li> + <li>item 1.7</li> + <li>item 1.8</li> + <li>item 1.9</li> + <li>item 1.10 added</li> + </ol> + </h1> + <h1 id="second section"> + <ol> + <li>item 2.1</li> + <li>item 2.2</li> + <li>item 2.3</li> + <li>item 2.4</li> + <li>item 2.5</li> + <li>item 2.6</li> + <li>item 2.7 changed</li> + <li>item 2.7.1 added</li> + <li>item 2.8</li> + </ol> + </h1> + <h1 id="third section"> + <ol> + <li>item 3.1</li> + <li>item 3.2</li> + <li>item 3.3</li> + <li>item 3.4</li> + <li>item 3.5</li> + <li>item 3.6</li> + </ol> + </h1> +</body> +</html> diff --git a/tests/resources/userdiff/after/file.javascript b/tests/resources/userdiff/after/file.javascript new file mode 100644 index 0000000..5391797 --- /dev/null +++ b/tests/resources/userdiff/after/file.javascript @@ -0,0 +1,108 @@ +define(function(require, exports, module) { + module.exports = Player; + + var Key = require("./key") + , Direction = require("./direction"); + + function Player(game) { + this.game = game; + + this.image = new Image("./assets/fighter.png"); + this.game.resources.add(this.image); + + this.x = 0; + this.y = 0; + + this.pixelX = 10; + this.pixelY = 10; + + this.animationStep = 0; + } + + Player.prototype.update = function() { + if (!this.isWalking()) { + this.handleInput(); + } + + if (this.isWalking()) { + // Increase the animation step. + this.animationStep = ++this.animationStep % 60; + + if (this.x * 32 > this.pixelX) { + this.pixelX++; + } else if (this.x * 32 < this.pixelX) { + this.pixelX--; + } + + if (this.y * 32 > this.pixelY) { + this.pixelY++; + } else if (this.y * 32 < this.pixelY) { + this.pixelY--; + } + } else { + // Reset the animation step. + this.animationStep = 0; + } + }; + + Player.prototype.handleInput = function() { + var keyboard = this.game.keyboard, finalAction, action, inputs = { + 'moveDown': keyboard.isDown(Key.DOWN), + 'moveUp': keyboard.isDown(Key.UP), + 'moveLeft': keyboard.isDown(Key.LEFT), + 'moveRight': keyboard.isDown(Key.RIGHT) + }; + + for (action in inputs) { + if (inputs[action]) { + if (!finalAction || inputs[finalAction] < inputs[action]) { + finalAction = action; + } + } + } + + this[finalAction] && this[finalAction](); + }; + + Player.prototype.isWalking = function() { + return this.x * 32 != this.pixelX || this.y * 32 != this.pixelY; + }; + + Player.prototype.moveDown = function() { + this.y += 1; + this.direction = Direction.DOWN; + }; + + Player.prototype.moveUp = function() { + this.y -= 1; + this.direction = Direction.UP; + }; + + Player.prototype.moveLeft = function() { + this.x -= 5; + this.direction = Direction.LEFT; + }; + + Player.prototype.moveRight = function() { + this.x += 1; + this.direction = Direction.RIGHT; + }; + + Player.prototype.draw = function(context) { + var offsetX = Math.floor(this.animationStep / 15) * 32, offsetY = 0; + + switch(this.direction) { + case Direction.UP: + offsetY = 48 * 3; + break; + case Direction.RIGHT: + offsetY = 48 * 2; + break; + case Direction.LEFT: + offsetY = 48; + break; + } + + context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48); + }; +}); diff --git a/tests/resources/userdiff/after/file.php b/tests/resources/userdiff/after/file.php new file mode 100644 index 0000000..967d646 --- /dev/null +++ b/tests/resources/userdiff/after/file.php @@ -0,0 +1,50 @@ +<?php + +namespace Faker; + +/** + * Proxy for other generators, to return only unique values. Works with + * Faker\Generator\Base->unique() + */ +class UniqueGenerator +{ + protected $generator; + protected $maxRetries; + protected $moreStuff; + protected $uniques = array(); + + public function __construct(Generator $generator, $maxRetries) + { + $this->generator = $generator; + $this->maxRetries = $maxRetries + 1; + } + + /** + * Catch and proxy all generator calls but return only unique values + */ + public function __get($attribute) + { + return $this->__call($attribute, array()); + } + + /** + * Catch and proxy all generator calls with arguments but return only unique values + */ + public function __call($name, $arguments) + { + $i = 0; + if (!isset($this->uniques[$name])) { + $this->uniques[$name] = array(); + } + do { + $res = call_user_func_array(array($this->generator, $name), $arguments); + $i++; + if ($i >= $this->maxRetries) { + throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); + } + } while (in_array($res, $this->uniques[$name])); + $this->uniques[$name][]= $res; + + return $res; + } +} diff --git a/tests/resources/userdiff/before/file.html b/tests/resources/userdiff/before/file.html new file mode 100644 index 0000000..872d196 --- /dev/null +++ b/tests/resources/userdiff/before/file.html @@ -0,0 +1,41 @@ +<html> +<body> + <h1 id="first section"> + <ol> + <li>item 1.1</li> + <li>item 1.2</li> + <li>item 1.3</li> + <li>item 1.4</li> + <li>item 1.5</li> + <li>item 1.6</li> + <li>item 1.7</li> + <li>item 1.8</li> + <li>item 1.9</li> + </ol> + </h1> + <h1 id="second section"> + <ol> + <li>item 2.1</li> + <li>item 2.2</li> + <li>item 2.3</li> + <li>item 2.4</li> + <li>item 2.5</li> + <li>item 2.6</li> + <li>item 2.7</li> + <li>item 2.8</li> + </ol> + </h1> + <h1 id="third section"> + <ol> + <li>item 3.1</li> + <li>item 3.2</li> + <li>item 3.3</li> + <li>item 3.4</li> + <li>item 3.5</li> + <li>item 3.6</li> + <li>item 3.7</li> + <li>item 3.8</li> + </ol> + </h1> +</body> +</html> diff --git a/tests/resources/userdiff/before/file.javascript b/tests/resources/userdiff/before/file.javascript new file mode 100644 index 0000000..0965b37 --- /dev/null +++ b/tests/resources/userdiff/before/file.javascript @@ -0,0 +1,109 @@ +define(function(require, exports, module) { + module.exports = Player; + + var Key = require("./key") + , Direction = require("./direction") + , Image = require("./image"); + + function Player(game) { + this.game = game; + + this.image = new Image("./assets/fighter.png"); + this.game.resources.add(this.image); + + this.x = 0; + this.y = 0; + + this.pixelX = 0; + this.pixelY = 0; + + this.animationStep = 0; + } + + Player.prototype.update = function() { + if (!this.isWalking()) { + this.handleInput(); + } + + if (this.isWalking()) { + // Increase the animation step. + this.animationStep = ++this.animationStep % 60; + + if (this.x * 32 > this.pixelX) { + this.pixelX++; + } else if (this.x * 32 < this.pixelX) { + this.pixelX--; + } + + if (this.y * 32 > this.pixelY) { + this.pixelY++; + } else if (this.y * 32 < this.pixelY) { + this.pixelY--; + } + } else { + // Reset the animation step. + this.animationStep = 0; + } + }; + + Player.prototype.handleInput = function() { + var keyboard = this.game.keyboard, finalAction, action, inputs = { + 'moveDown': keyboard.isDown(Key.DOWN), + 'moveUp': keyboard.isDown(Key.UP), + 'moveLeft': keyboard.isDown(Key.LEFT), + 'moveRight': keyboard.isDown(Key.RIGHT) + }; + + for (action in inputs) { + if (inputs[action]) { + if (!finalAction || inputs[finalAction] < inputs[action]) { + finalAction = action; + } + } + } + + this[finalAction] && this[finalAction](); + }; + + Player.prototype.isWalking = function() { + return this.x * 32 != this.pixelX || this.y * 32 != this.pixelY; + }; + + Player.prototype.moveDown = function() { + this.y += 1; + this.direction = Direction.DOWN; + }; + + Player.prototype.moveUp = function() { + this.y -= 1; + this.direction = Direction.UP; + }; + + Player.prototype.moveLeft = function() { + this.x -= 1; + this.direction = Direction.LEFT; + }; + + Player.prototype.moveRight = function() { + this.x += 1; + this.direction = Direction.RIGHT; + }; + + Player.prototype.draw = function(context) { + var offsetX = Math.floor(this.animationStep / 15) * 32, offsetY = 0; + + switch(this.direction) { + case Direction.UP: + offsetY = 48 * 3; + break; + case Direction.RIGHT: + offsetY = 48 * 2; + break; + case Direction.LEFT: + offsetY = 48; + break; + } + + context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY - 16, 32, 48); + }; +}); diff --git a/tests/resources/userdiff/before/file.php b/tests/resources/userdiff/before/file.php new file mode 100644 index 0000000..63250ad --- /dev/null +++ b/tests/resources/userdiff/before/file.php @@ -0,0 +1,49 @@ +<?php + +namespace Faker; + +/** + * Proxy for other generators, to return only unique values. Works with + * Faker\Generator\Base->unique() + */ +class UniqueGenerator +{ + protected $generator; + protected $maxRetries; + protected $uniques = array(); + + public function __construct(Generator $generator, $maxRetries) + { + $this->generator = $generator; + $this->maxRetries = $maxRetries; + } + + /** + * Catch and proxy all generator calls but return only unique values + */ + public function __get($attribute) + { + return $this->__call($attribute, array()); + } + + /** + * Catch and proxy all generator calls with arguments but return only unique values + */ + public function __call($name, $arguments) + { + if (!isset($this->uniques[$name])) { + $this->uniques[$name] = array(); + } + $i = 0; + do { + $res = call_user_func_array(array($this->generator, $name), $arguments); + $i++; + if ($i > $this->maxRetries) { + throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); + } + } while (in_array($res, $this->uniques[$name])); + $this->uniques[$name][]= $res; + + return $res; + } +} diff --git a/tests/resources/userdiff/expected/driver/diff.html b/tests/resources/userdiff/expected/driver/diff.html new file mode 100644 index 0000000..5a428e7 --- /dev/null +++ b/tests/resources/userdiff/expected/driver/diff.html @@ -0,0 +1,26 @@ +diff --git a/files/file.html b/files/file.html +index 872d196..2320e2f 100644 +--- a/files/file.html ++++ b/files/file.html +@@ -5,4 +5,4 @@ <h1 id="first section"> + <li>item 1.1</li> +- <li>item 1.2</li> +- <li>item 1.3</li> ++ <li>item 1.2 changed</li> ++ <li>item 1.3 changed</li> + <li>item 1.4</li> +@@ -13,2 +13,3 @@ <h1 id="first section"> + <li>item 1.9</li> ++ <li>item 1.10 added</li> + </ol> +@@ -23,3 +24,4 @@ <h1 id="second section"> + <li>item 2.6</li> +- <li>item 2.7</li> ++ <li>item 2.7 changed</li> ++ <li>item 2.7.1 added</li> + <li>item 2.8</li> +@@ -35,4 +37,2 @@ <h1 id="third section"> + <li>item 3.6</li> +- <li>item 3.7</li> +- <li>item 3.8</li> + </ol> diff --git a/tests/resources/userdiff/expected/driver/diff.javascript b/tests/resources/userdiff/expected/driver/diff.javascript new file mode 100644 index 0000000..4cefe5c --- /dev/null +++ b/tests/resources/userdiff/expected/driver/diff.javascript @@ -0,0 +1,27 @@ +diff --git a/files/file.javascript b/files/file.javascript +index 0965b37..5391797 100644 +--- a/files/file.javascript ++++ b/files/file.javascript +@@ -4,4 +4,3 @@ function(require, exports, module) + var Key = require("./key") +- , Direction = require("./direction") +- , Image = require("./image"); ++ , Direction = require("./direction"); + +@@ -16,4 +15,4 @@ function Player(game) + +- this.pixelX = 0; +- this.pixelY = 0; ++ this.pixelX = 10; ++ this.pixelY = 10; + +@@ -82,3 +81,3 @@ Player.prototype.moveUp = function() + Player.prototype.moveLeft = function() { +- this.x -= 1; ++ this.x -= 5; + this.direction = Direction.LEFT; +@@ -106,3 +105,3 @@ Player.prototype.draw = function(context) + +- context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY - 16, 32, 48); ++ context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48); + }; diff --git a/tests/resources/userdiff/expected/driver/diff.php b/tests/resources/userdiff/expected/driver/diff.php new file mode 100644 index 0000000..9711b5b --- /dev/null +++ b/tests/resources/userdiff/expected/driver/diff.php @@ -0,0 +1,26 @@ +diff --git a/files/file.php b/files/file.php +index 63250ad..967d646 100644 +--- a/files/file.php ++++ b/files/file.php +@@ -12,2 +12,3 @@ class UniqueGenerator + protected $maxRetries; ++ protected $moreStuff; + protected $uniques = array(); +@@ -17,3 +18,3 @@ public function __construct(Generator $generator, $maxRetries) + $this->generator = $generator; +- $this->maxRetries = $maxRetries; ++ $this->maxRetries = $maxRetries + 1; + } +@@ -33,10 +34,10 @@ public function __call($name, $arguments) + { ++ $i = 0; + if (!isset($this->uniques[$name])) { + $this->uniques[$name] = array(); + } +- $i = 0; + do { + $res = call_user_func_array(array($this->generator, $name), $arguments); + $i++; +- if ($i > $this->maxRetries) { ++ if ($i >= $this->maxRetries) { + throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); diff --git a/tests/resources/userdiff/expected/nodriver/diff.html b/tests/resources/userdiff/expected/nodriver/diff.html new file mode 100644 index 0000000..2ea4b8a --- /dev/null +++ b/tests/resources/userdiff/expected/nodriver/diff.html @@ -0,0 +1,26 @@ +diff --git a/files/file.html b/files/file.html +index 872d196..2320e2f 100644 +--- a/files/file.html ++++ b/files/file.html +@@ -5,4 +5,4 @@ + <li>item 1.1</li> +- <li>item 1.2</li> +- <li>item 1.3</li> ++ <li>item 1.2 changed</li> ++ <li>item 1.3 changed</li> + <li>item 1.4</li> +@@ -13,2 +13,3 @@ + <li>item 1.9</li> ++ <li>item 1.10 added</li> + </ol> +@@ -23,3 +24,4 @@ + <li>item 2.6</li> +- <li>item 2.7</li> ++ <li>item 2.7 changed</li> ++ <li>item 2.7.1 added</li> + <li>item 2.8</li> +@@ -35,4 +37,2 @@ + <li>item 3.6</li> +- <li>item 3.7</li> +- <li>item 3.8</li> + </ol> diff --git a/tests/resources/userdiff/expected/nodriver/diff.javascript b/tests/resources/userdiff/expected/nodriver/diff.javascript new file mode 100644 index 0000000..4bbd547 --- /dev/null +++ b/tests/resources/userdiff/expected/nodriver/diff.javascript @@ -0,0 +1,27 @@ +diff --git a/files/file.javascript b/files/file.javascript +index 0965b37..5391797 100644 +--- a/files/file.javascript ++++ b/files/file.javascript +@@ -4,4 +4,3 @@ define(function(require, exports, module) { + var Key = require("./key") +- , Direction = require("./direction") +- , Image = require("./image"); ++ , Direction = require("./direction"); + +@@ -16,4 +15,4 @@ define(function(require, exports, module) { + +- this.pixelX = 0; +- this.pixelY = 0; ++ this.pixelX = 10; ++ this.pixelY = 10; + +@@ -82,3 +81,3 @@ define(function(require, exports, module) { + Player.prototype.moveLeft = function() { +- this.x -= 1; ++ this.x -= 5; + this.direction = Direction.LEFT; +@@ -106,3 +105,3 @@ define(function(require, exports, module) { + +- context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY - 16, 32, 48); ++ context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48); + }; diff --git a/tests/resources/userdiff/expected/nodriver/diff.php b/tests/resources/userdiff/expected/nodriver/diff.php new file mode 100644 index 0000000..e77c094 --- /dev/null +++ b/tests/resources/userdiff/expected/nodriver/diff.php @@ -0,0 +1,26 @@ +diff --git a/files/file.php b/files/file.php +index 63250ad..967d646 100644 +--- a/files/file.php ++++ b/files/file.php +@@ -12,2 +12,3 @@ class UniqueGenerator + protected $maxRetries; ++ protected $moreStuff; + protected $uniques = array(); +@@ -17,3 +18,3 @@ class UniqueGenerator + $this->generator = $generator; +- $this->maxRetries = $maxRetries; ++ $this->maxRetries = $maxRetries + 1; + } +@@ -33,10 +34,10 @@ class UniqueGenerator + { ++ $i = 0; + if (!isset($this->uniques[$name])) { + $this->uniques[$name] = array(); + } +- $i = 0; + do { + $res = call_user_func_array(array($this->generator, $name), $arguments); + $i++; +- if ($i > $this->maxRetries) { ++ if ($i >= $this->maxRetries) { + throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); diff --git a/tests/resources/userdiff/files/file.html b/tests/resources/userdiff/files/file.html new file mode 100644 index 0000000..2320e2f --- /dev/null +++ b/tests/resources/userdiff/files/file.html @@ -0,0 +1,41 @@ +<html> +<body> + <h1 id="first section"> + <ol> + <li>item 1.1</li> + <li>item 1.2 changed</li> + <li>item 1.3 changed</li> + <li>item 1.4</li> + <li>item 1.5</li> + <li>item 1.6</li> + <li>item 1.7</li> + <li>item 1.8</li> + <li>item 1.9</li> + <li>item 1.10 added</li> + </ol> + </h1> + <h1 id="second section"> + <ol> + <li>item 2.1</li> + <li>item 2.2</li> + <li>item 2.3</li> + <li>item 2.4</li> + <li>item 2.5</li> + <li>item 2.6</li> + <li>item 2.7 changed</li> + <li>item 2.7.1 added</li> + <li>item 2.8</li> + </ol> + </h1> + <h1 id="third section"> + <ol> + <li>item 3.1</li> + <li>item 3.2</li> + <li>item 3.3</li> + <li>item 3.4</li> + <li>item 3.5</li> + <li>item 3.6</li> + </ol> + </h1> +</body> +</html> diff --git a/tests/resources/userdiff/files/file.javascript b/tests/resources/userdiff/files/file.javascript new file mode 100644 index 0000000..5391797 --- /dev/null +++ b/tests/resources/userdiff/files/file.javascript @@ -0,0 +1,108 @@ +define(function(require, exports, module) { + module.exports = Player; + + var Key = require("./key") + , Direction = require("./direction"); + + function Player(game) { + this.game = game; + + this.image = new Image("./assets/fighter.png"); + this.game.resources.add(this.image); + + this.x = 0; + this.y = 0; + + this.pixelX = 10; + this.pixelY = 10; + + this.animationStep = 0; + } + + Player.prototype.update = function() { + if (!this.isWalking()) { + this.handleInput(); + } + + if (this.isWalking()) { + // Increase the animation step. + this.animationStep = ++this.animationStep % 60; + + if (this.x * 32 > this.pixelX) { + this.pixelX++; + } else if (this.x * 32 < this.pixelX) { + this.pixelX--; + } + + if (this.y * 32 > this.pixelY) { + this.pixelY++; + } else if (this.y * 32 < this.pixelY) { + this.pixelY--; + } + } else { + // Reset the animation step. + this.animationStep = 0; + } + }; + + Player.prototype.handleInput = function() { + var keyboard = this.game.keyboard, finalAction, action, inputs = { + 'moveDown': keyboard.isDown(Key.DOWN), + 'moveUp': keyboard.isDown(Key.UP), + 'moveLeft': keyboard.isDown(Key.LEFT), + 'moveRight': keyboard.isDown(Key.RIGHT) + }; + + for (action in inputs) { + if (inputs[action]) { + if (!finalAction || inputs[finalAction] < inputs[action]) { + finalAction = action; + } + } + } + + this[finalAction] && this[finalAction](); + }; + + Player.prototype.isWalking = function() { + return this.x * 32 != this.pixelX || this.y * 32 != this.pixelY; + }; + + Player.prototype.moveDown = function() { + this.y += 1; + this.direction = Direction.DOWN; + }; + + Player.prototype.moveUp = function() { + this.y -= 1; + this.direction = Direction.UP; + }; + + Player.prototype.moveLeft = function() { + this.x -= 5; + this.direction = Direction.LEFT; + }; + + Player.prototype.moveRight = function() { + this.x += 1; + this.direction = Direction.RIGHT; + }; + + Player.prototype.draw = function(context) { + var offsetX = Math.floor(this.animationStep / 15) * 32, offsetY = 0; + + switch(this.direction) { + case Direction.UP: + offsetY = 48 * 3; + break; + case Direction.RIGHT: + offsetY = 48 * 2; + break; + case Direction.LEFT: + offsetY = 48; + break; + } + + context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48); + }; +}); diff --git a/tests/resources/userdiff/files/file.php b/tests/resources/userdiff/files/file.php new file mode 100644 index 0000000..967d646 --- /dev/null +++ b/tests/resources/userdiff/files/file.php @@ -0,0 +1,50 @@ +<?php + +namespace Faker; + +/** + * Proxy for other generators, to return only unique values. Works with + * Faker\Generator\Base->unique() + */ +class UniqueGenerator +{ + protected $generator; + protected $maxRetries; + protected $moreStuff; + protected $uniques = array(); + + public function __construct(Generator $generator, $maxRetries) + { + $this->generator = $generator; + $this->maxRetries = $maxRetries + 1; + } + + /** + * Catch and proxy all generator calls but return only unique values + */ + public function __get($attribute) + { + return $this->__call($attribute, array()); + } + + /** + * Catch and proxy all generator calls with arguments but return only unique values + */ + public function __call($name, $arguments) + { + $i = 0; + if (!isset($this->uniques[$name])) { + $this->uniques[$name] = array(); + } + do { + $res = call_user_func_array(array($this->generator, $name), $arguments); + $i++; + if ($i >= $this->maxRetries) { + throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); + } + } while (in_array($res, $this->uniques[$name])); + $this->uniques[$name][]= $res; + + return $res; + } +} |