Skip to content
Browse files

pulled requires out of beforeAll in compiled tests

  • Loading branch information...
1 parent 35bfa99 commit 2274832de841e5a31d1e359ec89e2cfee6907ae9 @doug-martin committed Feb 28, 2013
Showing with 6 additions and 129 deletions.
  1. +0 −123 examples/index.html
  2. +6 −6 test/flow.compiled.test.js
View
123 examples/index.html
@@ -1,123 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Conways</title>
- <link type="text/css" rel="stylesheet" href="assets/conways.css">
- <link href='http://fonts.googleapis.com/css?family=Londrina+Shadow' rel='stylesheet' type='text/css'>
-</head>
-<body onload="init()">
-
-<div class="container">
- <header>
- <h1>Conways Game Of Life</h1>
- </header>
-
- <div id="grid"></div>
- <hr>
- <h2>
- Pattern
- </h2>
- <textarea id="pattern">
- [
- [false, true, false],
- [false, true, false],
- [false, true, false]
- ]
- </textarea>
-
- <form>
- <input type="submit" id="run" value="Run!"/>
- <input type="button" id="stop" value="Stop"/>
- </form>
-</div>
-
-<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
-<script type="text/javascript" src="../../nools.js"></script>
-<script type="text/javascript" src="./rules/conways.js"></script>
-<script type="text/javascript">
-
- var init = (function () {
- var flow = nools.getFlow("conways"), Cell = flow.getDefined("Cell"), session;
- var run = (function () {
-
- var grid = $("#grid"), cells = [], rows = 30, cols = 30;
-
- function addCell(row, col, cell) {
- if (!cells[row]) {
- cells[row] = [];
- }
- cells[row][col] = cell;
- return cell;
- }
-
- function createPattern(pattern) {
- var cell;
- for (var i = 0; i < rows; i++) {
- var row = $("<div class='row'></div>").appendTo(grid);
- for (var j = 0; j < cols; j++) {
- cell = addCell(i, j, new Cell());
- cell.el = $("<div class='col dead'></div>").appendTo(row);
- if (pattern[i] && pattern[i][j]) {
- cell.state = "live";
- cell.el.removeClass("dead").addClass("live");
- }
- if (i > 0) {
- cell.addNeighbor(cells[i - 1][j]);
- if (j <= (cols - 2)) {
- // neighbor to the northeast
- cell.addNeighbor(cells[i - 1][j + 1]);
- }
- }
- if (j > 0) {
- // neighbor to the west
- cell.addNeighbor(cells[i][j - 1]);
- if (i > 0) {
- // neighbor to the northwest
- cell.addNeighbor(cells[i - 1][j - 1]);
- }
- }
- }
- }
- return cell;
- }
-
- return function (pattern) {
- grid.empty();
- createPattern(pattern);
- session = flow.getSession("populate", cells);
- session.on("cell-transition", function (cell) {
- if (cell.state === "live") {
- cell.el.removeClass("dead").addClass("live");
- } else {
- cell.el.removeClass("live").addClass("dead");
- }
- });
- return session.match().then(function () {
- session.dispose();
- });
- };
- }());
-
- return function () {
- //setup grid;
- run([]);
- $("form").on("submit", function () {
- run(eval("(0, " + $("#pattern").val() + ")"))
- return false;
- });
-
- $("#stop").on("click", function () {
- if (session) {
- session.dispose();
- }
- //clear grid;
- run([]);
- })
- };
- }());
-</script>
-
-</body>
-</html>
View
12 test/flow.compiled.test.js
@@ -9,8 +9,8 @@ it.describe("Flow compiled",function (it) {
var called, flow;
+ require("./rules/notRule-compiled");
it.beforeAll(function () {
- require("./rules/notRule-compiled");
flow = nools.getFlow("notRule-compiled");
called = new (flow.getDefined("count"))();
});
@@ -41,8 +41,8 @@ it.describe("Flow compiled",function (it) {
it.describe("or rule", function (it) {
var called, flow;
+ require("./rules/orRule-compiled");
it.beforeAll(function () {
- require("./rules/orRule-compiled");
flow = nools.getFlow("orRule-compiled");
called = new (flow.getDefined("count"))();
});
@@ -58,8 +58,8 @@ it.describe("Flow compiled",function (it) {
it.describe("scoped functions", function (it) {
var session, Message;
+ require("./rules/scope-compiled");
it.beforeAll(function () {
- require("./rules/scope-compiled");
var flow = nools.getFlow("scope-compiled");
Message = flow.getDefined("message");
session = flow.getSession();
@@ -80,8 +80,8 @@ it.describe("Flow compiled",function (it) {
it.timeout(1000);
var flow, Message, session;
+ require("./rules/simple-compiled");
it.beforeAll(function () {
- require("./rules/simple-compiled");
flow = nools.getFlow("simple-compiled");
Message = flow.getDefined("Message");
@@ -142,9 +142,9 @@ it.describe("Flow compiled",function (it) {
it.describe("fibonacci nools dsl", function (it) {
+ require("./rules/fibonacci-compiled");
var flow, Fibonacci, Result;
it.beforeAll(function () {
- require("./rules/fibonacci-compiled");
flow = nools.getFlow("fibonacci-compiled");
Fibonacci = flow.getDefined("fibonacci");
Result = flow.getDefined("result");
@@ -187,8 +187,8 @@ it.describe("Flow compiled",function (it) {
var flow, Patient;
+ require("./rules/diagnosis-compiled");
it.beforeAll(function () {
- require("./rules/diagnosis-compiled");
flow = nools.getFlow("diagnosis-compiled");
Patient = flow.getDefined("patient");
});

0 comments on commit 2274832

Please sign in to comment.
Something went wrong with that request. Please try again.