Permalink
Browse files

test files for quicker field testing

  • Loading branch information...
1 parent acbcd84 commit 2275d211464cab97f723cee682c4b5c952884438 @mrclay committed Mar 15, 2012
Showing with 110 additions and 0 deletions.
  1. +6 −0 README.txt
  2. +30 −0 min/quick-test.css
  3. +74 −0 min/quick-test.js
View
@@ -21,6 +21,12 @@ INSTALLATION
Place the /min/ directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: /home/example/www/min
+You can see verify that it is working by visiting these two URLs:
+ http://example.org/min/?f=min/quick-test.js
+ http://example.org/min/?f=min/quick-test.css
+
+If your server supports mod_rewrite, this URL should also work:
+ http://example.org/min/f=min/quick-test.js
CONFIGURATION & USAGE
View
@@ -0,0 +1,30 @@
+/*! This file exists only for testing a Minify installation. It's content is not used.
+ *
+ * http://example.org/min/f=min/quick-test.css
+ */
+
+@import url( /more.css );
+
+ body, td, th {
+ font-family: Verdana , "Bitstream Vera Sans" , Arial Narrow, sans-serif ;
+
+ font-size : 12px;
+}
+
+.nav {
+ margin-left: 20%;
+}
+#main-nav {
+ background-color: red;
+ border: 1px solid #00ff77;
+}
+
+div#content
+h1 + p {
+ padding-top: 0;
+ margin-top: 0;
+}
+
+@media all and (min-width: 640px) {
+ #media-queries-1 { background-color: #0f0; }
+}
View
@@ -0,0 +1,74 @@
+/*! This file exists only for testing a Minify installation. It's content is not used.
+ *
+ * http://example.org/min/f=min/quick-test.js
+ */
+
+/* Finds the lowest common multiple of two numbers */
+function LCMCalculator(x, y) { // constructor function
+ var checkInt = function (x) { // inner function
+ if (x % 1 !== 0) {
+ throw new TypeError(x + " is not an integer"); // throw an exception
+ }
+ return x;
+ };
+ this.a = checkInt(x);
+ // ^ semicolons are optional
+ this.b = checkInt(y);
+}
+// The prototype of object instances created by a constructor is
+// that constructor's "prototype" property.
+LCMCalculator.prototype = { // object literal
+ constructor: LCMCalculator, // when reassigning a prototype, set the constructor property appropriately
+ gcd: function () { // method that calculates the greatest common divisor
+ // Euclidean algorithm:
+ var a = Math.abs(this.a), b = Math.abs(this.b), t;
+ if (a < b) {
+ // swap variables
+ t = b;
+ b = a;
+ a = t;
+ }
+ while (b !== 0) {
+ t = b;
+ b = a % b;
+ a = t;
+ }
+ // Only need to calculate GCD once, so "redefine" this method.
+ // (Actually not redefinition - it's defined on the instance itself,
+ // so that this.gcd refers to this "redefinition" instead of LCMCalculator.prototype.gcd.)
+ // Also, 'gcd' === "gcd", this['gcd'] === this.gcd
+ this['gcd'] = function () {
+ return a;
+ };
+ return a;
+ },
+ // Object property names can be specified by strings delimited by double (") or single (') quotes.
+ "lcm" : function () {
+ // Variable names don't collide with object properties, e.g. |lcm| is not |this.lcm|.
+ // not using |this.a * this.b| to avoid FP precision issues
+ var lcm = this.a / this.gcd() * this.b;
+ // Only need to calculate lcm once, so "redefine" this method.
+ this.lcm = function () {
+ return lcm;
+ };
+ return lcm;
+ },
+ toString: function () {
+ return "LCMCalculator: a = " + this.a + ", b = " + this.b;
+ }
+};
+
+//define generic output function; this implementation only works for web browsers
+function output(x) {
+ document.write(x + "<br>");
+}
+
+// Note: Array's map() and forEach() are defined in JavaScript 1.6.
+// They are used here to demonstrate JavaScript's inherent functional nature.
+[[25, 55], [21, 56], [22, 58], [28, 56]].map(function (pair) { // array literal + mapping function
+ return new LCMCalculator(pair[0], pair[1]);
+}).sort(function (a, b) { // sort with this comparative function
+ return a.lcm() - b.lcm();
+}).forEach(function (obj) {
+ output(obj + ", gcd = " + obj.gcd() + ", lcm = " + obj.lcm());
+});

0 comments on commit 2275d21

Please sign in to comment.