summaryrefslogtreecommitdiffstats
path: root/tests/resources/userdiff/after
diff options
context:
space:
mode:
Diffstat (limited to 'tests/resources/userdiff/after')
-rw-r--r--tests/resources/userdiff/after/file.html41
-rw-r--r--tests/resources/userdiff/after/file.javascript108
-rw-r--r--tests/resources/userdiff/after/file.php50
3 files changed, 199 insertions, 0 deletions
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;
+ }
+}