From 29b5ab554790bb57337a3b6ab9dcd963cf69d22e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:47:08 +0200 Subject: Adding upstream version 1.7.2+ds. Signed-off-by: Daniel Baumann --- tests/resources/userdiff/.gitted/HEAD | 1 + tests/resources/userdiff/.gitted/config | 7 ++ tests/resources/userdiff/.gitted/description | 1 + tests/resources/userdiff/.gitted/index | Bin 0 -> 1558 bytes tests/resources/userdiff/.gitted/info/refs | 1 + .../09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 | Bin 0 -> 850 bytes .../0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc | Bin 0 -> 120 bytes .../39/ea75107a09091ba54ff86fcc780b59477e42cd | Bin 0 -> 854 bytes .../3c/c08384deae5957247bc36776ab626cc9e0582b | Bin 0 -> 116 bytes .../46/8d6f2afc940e14c76347fa9af26e429a3c9044 | Bin 0 -> 851 bytes .../53/917973acfe0111f93c2cfaacf854be245880e8 | Bin 0 -> 846 bytes .../63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 | Bin 0 -> 183 bytes .../f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd | Bin 0 -> 117 bytes .../resources/userdiff/.gitted/objects/info/packs | 2 + ...ck-1652578900ac63564f2a24b9714529821276ceb9.idx | Bin 0 -> 2500 bytes ...k-1652578900ac63564f2a24b9714529821276ceb9.pack | Bin 0 -> 7102 bytes tests/resources/userdiff/.gitted/packed-refs | 2 + .../userdiff/.gitted/refs/dummy-marker.txt | 0 tests/resources/userdiff/after/file.html | 41 ++++++++ tests/resources/userdiff/after/file.javascript | 108 ++++++++++++++++++++ tests/resources/userdiff/after/file.php | 50 ++++++++++ tests/resources/userdiff/before/file.html | 41 ++++++++ tests/resources/userdiff/before/file.javascript | 109 +++++++++++++++++++++ tests/resources/userdiff/before/file.php | 49 +++++++++ tests/resources/userdiff/expected/driver/diff.html | 26 +++++ .../userdiff/expected/driver/diff.javascript | 27 +++++ tests/resources/userdiff/expected/driver/diff.php | 26 +++++ .../resources/userdiff/expected/nodriver/diff.html | 26 +++++ .../userdiff/expected/nodriver/diff.javascript | 27 +++++ .../resources/userdiff/expected/nodriver/diff.php | 26 +++++ tests/resources/userdiff/files/file.html | 41 ++++++++ tests/resources/userdiff/files/file.javascript | 108 ++++++++++++++++++++ tests/resources/userdiff/files/file.php | 50 ++++++++++ 33 files changed, 769 insertions(+) create mode 100644 tests/resources/userdiff/.gitted/HEAD create mode 100644 tests/resources/userdiff/.gitted/config create mode 100644 tests/resources/userdiff/.gitted/description create mode 100644 tests/resources/userdiff/.gitted/index create mode 100644 tests/resources/userdiff/.gitted/info/refs create mode 100644 tests/resources/userdiff/.gitted/objects/09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 create mode 100644 tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc create mode 100644 tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd create mode 100644 tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b create mode 100644 tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 create mode 100644 tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 create mode 100644 tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 create mode 100644 tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd create mode 100644 tests/resources/userdiff/.gitted/objects/info/packs create mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx create mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack create mode 100644 tests/resources/userdiff/.gitted/packed-refs create mode 100644 tests/resources/userdiff/.gitted/refs/dummy-marker.txt create mode 100644 tests/resources/userdiff/after/file.html create mode 100644 tests/resources/userdiff/after/file.javascript create mode 100644 tests/resources/userdiff/after/file.php create mode 100644 tests/resources/userdiff/before/file.html create mode 100644 tests/resources/userdiff/before/file.javascript create mode 100644 tests/resources/userdiff/before/file.php create mode 100644 tests/resources/userdiff/expected/driver/diff.html create mode 100644 tests/resources/userdiff/expected/driver/diff.javascript create mode 100644 tests/resources/userdiff/expected/driver/diff.php create mode 100644 tests/resources/userdiff/expected/nodriver/diff.html create mode 100644 tests/resources/userdiff/expected/nodriver/diff.javascript create mode 100644 tests/resources/userdiff/expected/nodriver/diff.php create mode 100644 tests/resources/userdiff/files/file.html create mode 100644 tests/resources/userdiff/files/file.javascript create mode 100644 tests/resources/userdiff/files/file.php (limited to 'tests/resources/userdiff') 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 new file mode 100644 index 0000000..548dc7b Binary files /dev/null and b/tests/resources/userdiff/.gitted/index differ 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 new file mode 100644 index 0000000..cbaf4c1 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/09/65b377c214bbe5e0d18fcdaf556df7fa7ed7c8 differ diff --git a/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc b/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc new file mode 100644 index 0000000..fa149da Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/0c/20ef1409ae1df4d5a76cdbd98d5c33ccdb6bcc differ diff --git a/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd b/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd new file mode 100644 index 0000000..7483736 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/39/ea75107a09091ba54ff86fcc780b59477e42cd differ diff --git a/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b b/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b new file mode 100644 index 0000000..29b72fb Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/3c/c08384deae5957247bc36776ab626cc9e0582b differ diff --git a/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 b/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 new file mode 100644 index 0000000..5fc8391 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/46/8d6f2afc940e14c76347fa9af26e429a3c9044 differ diff --git a/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 b/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 new file mode 100644 index 0000000..debf7e4 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/53/917973acfe0111f93c2cfaacf854be245880e8 differ diff --git a/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 b/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 new file mode 100644 index 0000000..e8b884c Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/63/1d44e0c72e8cd1b594fa11d7d1ee8a6d67ff67 differ diff --git a/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd b/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd new file mode 100644 index 0000000..cfbef99 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/f3/be389d351e4bcc6dcc4b5fe22134ef0f63f8bd differ 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 new file mode 100644 index 0000000..6f4381c Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx differ diff --git a/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack new file mode 100644 index 0000000..39bd1d8 Binary files /dev/null and b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.pack differ 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 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 @@ + + +

+
    +
  1. item 1.1
  2. +
  3. item 1.2 changed
  4. +
  5. item 1.3 changed
  6. +
  7. item 1.4
  8. +
  9. item 1.5
  10. +
  11. item 1.6
  12. +
  13. item 1.7
  14. +
  15. item 1.8
  16. +
  17. item 1.9
  18. +
  19. item 1.10 added
  20. +
+

+

+
    +
  1. item 2.1
  2. +
  3. item 2.2
  4. +
  5. item 2.3
  6. +
  7. item 2.4
  8. +
  9. item 2.5
  10. +
  11. item 2.6
  12. +
  13. item 2.7 changed
  14. +
  15. item 2.7.1 added
  16. +
  17. item 2.8
  18. +
+

+

+
    +
  1. item 3.1
  2. +
  3. item 3.2
  4. +
  5. item 3.3
  6. +
  7. item 3.4
  8. +
  9. item 3.5
  10. +
  11. item 3.6
  12. +
+

+ + 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 @@ +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 @@ + + +

+
    +
  1. item 1.1
  2. +
  3. item 1.2
  4. +
  5. item 1.3
  6. +
  7. item 1.4
  8. +
  9. item 1.5
  10. +
  11. item 1.6
  12. +
  13. item 1.7
  14. +
  15. item 1.8
  16. +
  17. item 1.9
  18. +
+

+

+
    +
  1. item 2.1
  2. +
  3. item 2.2
  4. +
  5. item 2.3
  6. +
  7. item 2.4
  8. +
  9. item 2.5
  10. +
  11. item 2.6
  12. +
  13. item 2.7
  14. +
  15. item 2.8
  16. +
+

+

+
    +
  1. item 3.1
  2. +
  3. item 3.2
  4. +
  5. item 3.3
  6. +
  7. item 3.4
  8. +
  9. item 3.5
  10. +
  11. item 3.6
  12. +
  13. item 3.7
  14. +
  15. item 3.8
  16. +
+

+ + 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 @@ +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 @@

+
  • item 1.1
  • +-
  • item 1.2
  • +-
  • item 1.3
  • ++
  • item 1.2 changed
  • ++
  • item 1.3 changed
  • +
  • item 1.4
  • +@@ -13,2 +13,3 @@

    +
  • item 1.9
  • ++
  • item 1.10 added
  • + +@@ -23,3 +24,4 @@

    +
  • item 2.6
  • +-
  • item 2.7
  • ++
  • item 2.7 changed
  • ++
  • item 2.7.1 added
  • +
  • item 2.8
  • +@@ -35,4 +37,2 @@

    +
  • item 3.6
  • +-
  • item 3.7
  • +-
  • item 3.8
  • + 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 @@ +
  • item 1.1
  • +-
  • item 1.2
  • +-
  • item 1.3
  • ++
  • item 1.2 changed
  • ++
  • item 1.3 changed
  • +
  • item 1.4
  • +@@ -13,2 +13,3 @@ +
  • item 1.9
  • ++
  • item 1.10 added
  • + +@@ -23,3 +24,4 @@ +
  • item 2.6
  • +-
  • item 2.7
  • ++
  • item 2.7 changed
  • ++
  • item 2.7.1 added
  • +
  • item 2.8
  • +@@ -35,4 +37,2 @@ +
  • item 3.6
  • +-
  • item 3.7
  • +-
  • item 3.8
  • + 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 @@ + + +

    +
      +
    1. item 1.1
    2. +
    3. item 1.2 changed
    4. +
    5. item 1.3 changed
    6. +
    7. item 1.4
    8. +
    9. item 1.5
    10. +
    11. item 1.6
    12. +
    13. item 1.7
    14. +
    15. item 1.8
    16. +
    17. item 1.9
    18. +
    19. item 1.10 added
    20. +
    +

    +

    +
      +
    1. item 2.1
    2. +
    3. item 2.2
    4. +
    5. item 2.3
    6. +
    7. item 2.4
    8. +
    9. item 2.5
    10. +
    11. item 2.6
    12. +
    13. item 2.7 changed
    14. +
    15. item 2.7.1 added
    16. +
    17. item 2.8
    18. +
    +

    +

    +
      +
    1. item 3.1
    2. +
    3. item 3.2
    4. +
    5. item 3.3
    6. +
    7. item 3.4
    8. +
    9. item 3.5
    10. +
    11. item 3.6
    12. +
    +

    + + 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 @@ +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; + } +} -- cgit v1.2.3