Skip to content
Browse files

Adding circular tests that include testing require, exports and modul…

…e, not working yet. Some file renaming.
  • Loading branch information...
1 parent bd7c2bd commit 10ba5d772c34b39fd3cc7956fddae9e39ce539d7 @jrburke jrburke committed May 16, 2011
View
3 tests/basic/a.js
@@ -0,0 +1,3 @@
+define('a', {
+ name: 'a'
+});
View
6 tests/basic/b.js
@@ -0,0 +1,6 @@
+define('b', ['sub/c'], function (c) {
+ return {
+ name: 'b',
+ cName: c.name
+ };
+});
View
33 tests/basic/circular-tests.js
@@ -0,0 +1,33 @@
+go( ["require", "two", "funcTwo", "funcThree"],
+function(require, two, funcTwo, funcThree) {
+ var args = two.doSomething(),
+ twoInst = new funcTwo("TWO"),
+ oneMod = two.getOneModule();
+
+ doh.register(
+ "circular",
+ [
+ function circular(t) {
+ t.is("small", args.size);
+ t.is("redtwo", args.color);
+ //Check CommonJS "module" property support.
+ t.is("one", oneMod.name);
+ t.is("one.js", oneMod.uri);
+ }
+ ]
+ );
+ doh.run();
+
+ doh.register(
+ "circularFunc",
+ [
+ function circularFunc(t) {
+ t.is("TWO", twoInst.name);
+ t.is("ONE-NESTED", twoInst.oneName());
+ t.is("THREE-THREE_SUFFIX", funcThree("THREE"));
+ }
+ ]
+ );
+ doh.run();
+ }
+);
View
13 tests/basic/circular.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Circular Dependencies</title>
+ <script src="../bootstrap.js"></script>
+ <script src="circular-tests.js"></script>
+</head>
+<body>
+ <h1>Circular Dependencies</h1>
+ <p>Support for circular dependencies, including use of 'exports'.</p>
+ <p>See console for output.</p>
+</body>
+</html>
View
0 tests/basic/defineAmd.js → tests/basic/defineAmd-tests.js
File renamed without changes.
View
2 tests/basic/defineAmd.html
@@ -3,7 +3,7 @@
<head>
<title>Define AMD</title>
<script src="../bootstrap.js"></script>
- <script src="defineAmd.js"></script>
+ <script src="defineAmd-tests.js"></script>
</head>
<body>
<h1>Define AMD</h1>
View
11 tests/basic/funcFour.js
@@ -0,0 +1,11 @@
+define("funcFour", ["require", "funcThree"], function (require) {
+ var four = function (arg) {
+ return "FOUR called with " + arg;
+ };
+
+ four.suffix = function () {
+ return require("funcThree").suffix();
+ };
+
+ return four;
+});
View
12 tests/basic/funcOne.js
@@ -0,0 +1,12 @@
+define("funcOne", ["require", "funcTwo"], function (require) {
+ var one = function (name) {
+ this.name = name;
+ };
+
+ one.prototype.getName = function () {
+ var inst = new (require("funcTwo"))("-NESTED");
+ return this.name + inst.name;
+ };
+
+ return one;
+});
View
11 tests/basic/funcThree.js
@@ -0,0 +1,11 @@
+define("funcThree", ["funcFour"], function (four) {
+ var three = function (arg) {
+ return arg + "-" + require("funcFour").suffix();
+ };
+
+ three.suffix = function () {
+ return "THREE_SUFFIX";
+ };
+
+ return three;
+});
View
12 tests/basic/funcTwo.js
@@ -0,0 +1,12 @@
+define("funcTwo", ["require", "funcOne"], function (require) {
+ var two = function (name) {
+ this.name = name;
+ this.one = new (require("funcOne"))("ONE");
+ };
+
+ two.prototype.oneName = function () {
+ return this.one.getName();
+ };
+
+ return two;
+});
View
8 tests/basic/one.js
@@ -1,3 +1,7 @@
-define('one', {
- name: 'one'
+define("one", ["require", "exports", "module", "two"], function(require, exports, module) {
+ exports.size = "large";
+ exports.module = module;
+ exports.doSomething = function() {
+ return require("two");
+ };
});
View
15 tests/basic/simple-tests.js
@@ -0,0 +1,15 @@
+go(['a', 'b'], function (a, b) {
+
+ doh.register(
+ "basic/simple",
+ [
+ function simple(t){
+ t.is('a', a.name);
+ t.is('b', b.name);
+ t.is('c', b.cName);
+ }
+ ]
+ );
+ doh.run();
+
+});
View
2 tests/basic/simple.html
@@ -3,7 +3,7 @@
<head>
<title>Simple named dependencies</title>
<script src="../bootstrap.js"></script>
- <script src="simple.js"></script>
+ <script src="simple-tests.js"></script>
</head>
<body>
<h1>Simple named dependencies</h1>
View
15 tests/basic/simple.js
@@ -1,15 +0,0 @@
-go(['one', 'two'], function (one, two) {
-
- doh.register(
- "basic/simple",
- [
- function simple(t){
- t.is('one', one.name);
- t.is('two', two.name);
- t.is('three', two.threeName);
- }
- ]
- );
- doh.run();
-
-});
View
5 tests/basic/sub/c.js
@@ -0,0 +1,5 @@
+define('sub/c', function () {
+ return {
+ name: 'c'
+ };
+});
View
5 tests/basic/sub/three.js
@@ -1,5 +0,0 @@
-define('sub/three', function () {
- return {
- name: 'three'
- };
-});
View
12 tests/basic/two.js
@@ -1,6 +1,12 @@
-define('two', ['sub/three'], function (three) {
+define("two", ["require", "one"], function(require, one) {
return {
- name: 'two',
- threeName: three.name
+ size: "small",
+ color: "redtwo",
+ doSomething: function() {
+ return one.doSomething();
+ },
+ getOneModule: function() {
+ return one.module;
+ }
};
});
View
7 tests/tests.js
@@ -15,11 +15,12 @@
basic: function () {
reg('basic/defineAmd');
reg('basic/simple');
+ reg('basic/circular');
}
- //basic: true, //include function callback and basic object callback.
- //simple circular dependencies
- //anonymous: true, //include function callback and basic object callback.
+ //basic: true, //include require, exports, module tests.
+ //anonymous: true, //include function callback and basic object callback,
+ //circular deps
//commonJsWrapper: true,
};

0 comments on commit 10ba5d7

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