Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding some tests for ConstantScope, fixing some inheritance order bugs.

  • Loading branch information...
commit 646df6ffcdc3c2dd7826dbf549a072b21112c890 1 parent 501c469
@jcoglan jcoglan authored
Showing with 27 additions and 1 deletion.
  1. +5 −1 source/constant_scope.js
  2. +22 −0 test/test.html
View
6 source/constant_scope.js
@@ -3,8 +3,12 @@ JS.ConstantScope = new JS.Module({
included: function(base) {
base.__consts__ = new JS.Module();
base.extend(this.ClassMethods);
+
base.include(base.__consts__);
base.extend(base.__consts__);
+
+ base.include(base.__mod__.__fns__);
+ base.extend(base.__eigen__().__fns__);
},
ClassMethods: new JS.Module({
@@ -34,9 +38,9 @@ JS.ConstantScope = new JS.Module({
delete inclusions[key];
if (object.isA && object.isA(JS.Module)) {
- object.include(this);
object.include(base.__consts__);
object.extend(base.__consts__);
+ object.include(this);
}
}
return constants;
View
22 test/test.html
@@ -1317,6 +1317,28 @@
assertEqual(933, this.counter);
}},
+ testConstants: function() { with(this) {
+ var Foo = new JS.Class({
+ include: JS.ConstantScope,
+
+ Item: new JS.Class({NAME: 'Outer'}),
+
+ Inner: new JS.Class({
+ Item: new JS.Class({NAME: 'Inner'}),
+
+ extend: {
+ get: function() {
+ return this.Item.NAME
+ }
+ }
+ })
+ });
+
+ assert(Foo.Item.NAME === Foo.Item.prototype.NAME);
+ assertEqual('Outer', Foo.Item.NAME);
+ assertEqual('Inner', Foo.Inner.get());
+ }},
+
testDecorator: function() { with(this) {
var bike = new Bicycle('BMX', 1);
var bikeWithHeadlights = new HeadlightDecorator(bike);
Please sign in to comment.
Something went wrong with that request. Please try again.