Comparing version 0.12.0 to 0.13.0
@@ -86,2 +86,3 @@ // ---------------------------------------------------------------------------- | ||
validation.checkInheritance(Child); | ||
validation.checkMisc(Child); | ||
@@ -88,0 +89,0 @@ return Child; |
@@ -170,3 +170,41 @@ var util = require('./util'); | ||
}); | ||
} | ||
}, | ||
// Check for any thing else we're trying to enforce | ||
checkMisc: function(C) | ||
{ | ||
// Check for fluent stuff | ||
var sClass = 'Class ' + C.__name__; | ||
_(core.getSignature(C)).each(function(info, key) { | ||
var s = validation.prettyPrint(key, info, C); | ||
if (info.decorations.FLUENT) { | ||
if (!_(info.value).isFunction()) { | ||
throw new TypedefException('fluent member ' + s + | ||
' must be function'); | ||
} | ||
var re = /return\s+([^;]+)/g; | ||
var body = info.value.toString(); | ||
var good = true; | ||
var matches = 0; | ||
var tots = 0; | ||
while ((match = re.exec(body))) | ||
{ | ||
tots++; | ||
if (match[1] == 'this') | ||
matches++; | ||
} | ||
if (!matches || matches != tots) { | ||
throw new TypedefException('fluent member ' + s + | ||
' must return own instance in all code paths'); | ||
} | ||
} | ||
}); | ||
}, | ||
}; |
{ | ||
"name": "typedef", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Familiar classes, mixins, and interfaces in ES5 Javascript. Member decorations for powerful objects that keep your code DRY", | ||
@@ -5,0 +5,0 @@ "main": "lib/typedef.js", |
@@ -9,1 +9,2 @@ // Run all tests | ||
require('./unit/global'); | ||
require('./unit/fluent'); |
108352
23
3208