Commits

urso committed 2ac8016

moved example directory to documentation/example

Comments (0)

Files changed (6)

documentation/example/basicuse.html

+<!DOCTYPE html>
+<head>
+<title>Basic Use of qc.js</title>
+<link rel="stylesheet" type="text/css" href="qcjsdoc.css">
+<script src="../src/qc.js"></script>
+
+<script src="http://www.google.com/jsapi"></script>
+<script>
+google.load("jquery", "1.3");
+google.setOnLoadCallback(function() {
+    $(document).ready(function() { runAllLiterate() });
+    });
+</script>
+<script src="literate.js"></script>
+</head>
+<body>
+<h2>Defining a basic property and checking it.</h2>
+<p>
+The core ethic of what we are doing with qc.js is coming up with
+"properties" our code should have and verifying that those properties
+actually hold in practice.
+
+Let's start with an example. Let's make a function that "intensifies"
+a number by 2.
+
+So if the function got a 7, the function would yield 9. If the
+function got a -3, it would return -5.
+
+We'll start with with an implementation that is obviously wrong. We'll
+define a qc.js property to check out some cases.
+</p>
+
+<p class="code runme" id="negative-bad">
+function intensify(n) {
+    return n + 2;
+}
+
+declare("intensify grows by 2", [arbInt],
+        function(c, a) {
+            var result = intensify(a);
+            c.noteArg(result);
+            c.assert(Math.abs(a) + 2 == Math.abs(result));
+        });
+</p>
+
+<p>
+Obviously that was going to fail and as we saw, negative numbers trip
+up our very naive implementation of intensify. So what happens if we
+do a better job?
+</p>
+
+<p class="code runme" id="intensify-pass">
+function intensify(n) {
+    if (n > 0) {
+        return n + 2;
+    } else {
+        return n - 2;
+    }
+}
+
+declare("intensify grows by 2", [arbInt],
+        function(c, a) {
+            var result = intensify(a);
+            c.noteArg(result);
+            c.assert(Math.abs(a) + 2 == Math.abs(result));
+        });
+</p>
+
+</body>

documentation/example/literate.js

+// A specialized listener which pokes results into a div with jquery.
+function LiterateListener(jqDest) {
+    this.jqDest = jqDest;
+}
+
+LiterateListener.prototype.noteResult = function(result) {
+    var status_string = result.status + ": " + result.name;
+    this.log(status_string);
+    this.logResult(result);
+    if (result.status == "pass") {
+	// do nothing.
+    } else {
+	this.jqDest.removeClass("green");
+	this.jqDest.addClass("red");
+    }
+    if (result.status == "fail") {
+        this.log("Failed case:");
+        this.log(result.failedCase.toString());
+    }
+};
+
+LiterateListener.prototype.done = function(result) {
+    this.log('done.');
+};
+
+LiterateListener.prototype.log = function(text) {
+    this.jqDest.append($('<span>' + text + '</span>'));
+    this.jqDest.append($('<br/>'));
+};
+
+LiterateListener.prototype.logResult = function(result) {
+    this.log("passes: " + result.stats.pass);
+    this.log("invalid: " + result.stats.invalid);
+}
+// Given a jquery identifier, run the code in the element and display
+// results in an helpful manner near the code.
+function literateRun(id) {
+    resetProps();
+    eval($(id).text());
+    var dest = $(id).after("<div>").next();
+    dest.addClass("test-result");
+    dest.addClass("green");
+    runAllProps(new Config(100, 1000), new LiterateListener(dest));
+}
+
+function runAllLiterate() {
+    $(".runme").each(function () {
+	    literateRun(this);
+	});
+}

documentation/example/qcjsdoc.css

+.code {
+    font-family: monospace;
+    white-space: pre;
+}
+
+.red {
+    background-color: #ff9999;
+}
+
+.green {
+    background-color: #99ff99;
+}
+
+.test-result {
+    padding: 0.7em;
+}

example/basicuse.html

-<!DOCTYPE html>
-<head>
-<title>Basic Use of qc.js</title>
-<link rel="stylesheet" type="text/css" href="qcjsdoc.css">
-<script src="../src/qc.js"></script>
-
-<script src="http://www.google.com/jsapi"></script>
-<script>
-google.load("jquery", "1.3");
-google.setOnLoadCallback(function() {
-    $(document).ready(function() { runAllLiterate() });
-    });
-</script>
-<script src="literate.js"></script>
-</head>
-<body>
-<h2>Defining a basic property and checking it.</h2>
-<p>
-The core ethic of what we are doing with qc.js is coming up with
-"properties" our code should have and verifying that those properties
-actually hold in practice.
-
-Let's start with an example. Let's make a function that "intensifies"
-a number by 2.
-
-So if the function got a 7, the function would yield 9. If the
-function got a -3, it would return -5.
-
-We'll start with with an implementation that is obviously wrong. We'll
-define a qc.js property to check out some cases.
-</p>
-
-<p class="code runme" id="negative-bad">
-function intensify(n) {
-    return n + 2;
-}
-
-declare("intensify grows by 2", [arbInt],
-        function(c, a) {
-            var result = intensify(a);
-            c.noteArg(result);
-            c.assert(Math.abs(a) + 2 == Math.abs(result));
-        });
-</p>
-
-<p>
-Obviously that was going to fail and as we saw, negative numbers trip
-up our very naive implementation of intensify. So what happens if we
-do a better job?
-</p>
-
-<p class="code runme" id="intensify-pass">
-function intensify(n) {
-    if (n > 0) {
-        return n + 2;
-    } else {
-        return n - 2;
-    }
-}
-
-declare("intensify grows by 2", [arbInt],
-        function(c, a) {
-            var result = intensify(a);
-            c.noteArg(result);
-            c.assert(Math.abs(a) + 2 == Math.abs(result));
-        });
-</p>
-
-</body>

example/literate.js

-// A specialized listener which pokes results into a div with jquery.
-function LiterateListener(jqDest) {
-    this.jqDest = jqDest;
-}
-
-LiterateListener.prototype.noteResult = function(result) {
-    var status_string = result.status + ": " + result.name;
-    this.log(status_string);
-    this.logResult(result);
-    if (result.status == "pass") {
-	// do nothing.
-    } else {
-	this.jqDest.removeClass("green");
-	this.jqDest.addClass("red");
-    }
-    if (result.status == "fail") {
-        this.log("Failed case:");
-        this.log(result.failedCase.toString());
-    }
-};
-
-LiterateListener.prototype.done = function(result) {
-    this.log('done.');
-};
-
-LiterateListener.prototype.log = function(text) {
-    this.jqDest.append($('<span>' + text + '</span>'));
-    this.jqDest.append($('<br/>'));
-};
-
-LiterateListener.prototype.logResult = function(result) {
-    this.log("passes: " + result.stats.pass);
-    this.log("invalid: " + result.stats.invalid);
-}
-// Given a jquery identifier, run the code in the element and display
-// results in an helpful manner near the code.
-function literateRun(id) {
-    resetProps();
-    eval($(id).text());
-    var dest = $(id).after("<div>").next();
-    dest.addClass("test-result");
-    dest.addClass("green");
-    runAllProps(new Config(100, 1000), new LiterateListener(dest));
-}
-
-function runAllLiterate() {
-    $(".runme").each(function () {
-	    literateRun(this);
-	});
-}

example/qcjsdoc.css

-.code {
-    font-family: monospace;
-    white-space: pre;
-}
-
-.red {
-    background-color: #ff9999;
-}
-
-.green {
-    background-color: #99ff99;
-}
-
-.test-result {
-    padding: 0.7em;
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.