mbreeze/jstd_amd — Issue #1: I constantly have null for loaded requirejs modules
Author: vprisivko
Created: 2012-02-22 17:47:51+00:00
State: open

// test/SegmentTest.js
```javascript
amdTestCase(
{
baseUrl:'/test',
testCase:'Segment test case'
},
['Segment.js'],
{
setUp: function () {
this.Segment = this.req('Segment.js');
},
'testMedian': function() {
var segment = new this.Segment(0, 1);
var median = segment.getMedian();
assertEquals(median, 0.5);
}
}
);
```

// test/Segment.js
```javascript
define(["./util.js"], function (util) {
function Segment(begin, end) {
util.assert(begin < end, begin, end);

this.begin = begin;
this.end = end;
}

Segment.prototype.intersectsWith = function (segment) {
return !(this.end <= segment.begin || segment.end <= this.begin);
};

Segment.prototype.getDistanceToPoint = function (x) {
if (this.begin <= x && x <= this.end)
return 0;

return Math.min(Math.abs(this.begin - x), Math.abs(x - this.end));
};

Segment.prototype.toString = function () {
return this.begin + ' ' + this.end;
};

Segment.prototype.getLength = function () {
return this.end - this.begin;
};

Segment.prototype.getMedian = function() {
return (this.begin + this.end) / 2;
};

Segment.prototype.belongsTo = function(segment) {
return segment.begin <= this.begin && this.end <= segment.end;
};

return Segment;
});
```

// test.jstd
```javascript
server: http://localhost:9876

load:
- src/lib/require-jquery.js
- test/amdTestCase.js

serve:
- test/Segment.js

test:
- test/SegmentTest.js
```

All paths a relative to test.jstd.

Running the test I am constantly getting null for *this.Segment*, and therefore the call *new this.Segment(0, 1)* fails.