ejhfast / typedjs Goto Github PK
View Code? Open in Web Editor NEWLightweight program specifications for testing JavaScript
Home Page: http://typedjs.com
Lightweight program specifications for testing JavaScript
Home Page: http://typedjs.com
The last function in the test is documented as maybe_char, but the last function is actually char_first -- which is the same function name as the previous.
run_tests_on_string
is not returning a value (returning undefined) on code with no type annotations:
197 if(types.length > 0){
198 var suite = [];
199 for(var i = 0; i < types.length; i++) {
200 var base = this.addTest(types[i], null, redefine);
201 suite.push(base);
202 }
203 return TypedJS.go(suite, redefine);
204 }
205 }
See: goatslacker/node-typedjs#4 goatslacker/node-typedjs#5
trivial patch coming
The main web site indicates (as does the function name) that add_all() will return the sum of all numbers in an array. It only returns the value of the last item in the array.
The code expresses "count" as the value being modified -- but it's not a "count" per se, its a value of the last item in the array.
Rather than trying to stick to a type signature, why not expand the idea to do something similar to what Mozilla is doing with contracts.coffee and leverage the type signatures plus other options as a form of contracts? I'm sure this is similar to what is already done; the point is more to not limit only to mimicking a type system since you don't have to stop there.
This is a very useful project, and I hope my thought here is taken in the context of my appreciation for what you've begun.
Do you intend to drop the jQuery dependency at some future point so that it can be used as part of a browserless development cycle? For example, I would like to be able to use TypedJS as a quick check inside a text editor/IDE to confirm that things check out, before heading to the browser. It would also be tremendously helpful to be able to do this for NodeJS code.
Any chance that we could use java docs - much more widely used IMHO than haskell-like
also means anyone who marked up fro google closure compiler can use this out the box
Will you be adding the jison grammar file?
But you knew that already :)
This looks interesting! But I think you might want to think more about your license choice; are you aware that the CC noncommercial license means that no-one at any company can use this code, even if they give back all of the changes they make to it? CC licenses are not usually used or recommended for source code.
(I'd recommend a BSD or AGPL license instead.)
Thanks.
I find this syntax (from the readme) confusing:
var test = TypedJS.addTest('concat :: String -> String -> String', concat);
TypedJS.go([test]);
The "addTest" function name suggests (to me) that TypedJS is maintaining an internal collection of the tests for which I'd expect to be able to call 'go' to run the current tests:
TypedJS.addTest('concat :: String -> String -> String', concat);
TypedJS.go();
Perhaps it would be more appropriate to rename "addTest" to "createTest" and "go" to "runTests"?
var tests = $.map([{
name: concat,
type: "concat :: String, String -> Boolean"},
{
name: add,
type: "add :: Number, Number -> Number"}], function(func) {
return TypedJS.createTest(func.type, func.name);
});
TypedJS.runTests(tests);โ
It's useful but it really isn't a type in JS. There's just String, IMHO this feature should be opt-in/opt-out.
Also, would be nice to add 'RegExp', 'Date', and 'isNaN'
Pull request coming at some point when GH-6 is fixed.
Jameshfisher of reddit made a good point:
http://www.reddit.com/r/javascript/comments/pholi/typedjs_sanity_check_your_code/c3pscxo
For example:
test1a = function (a) { return true; }
tested with
test = TypedJS.addTest("test1a :: Number -> Boolean", test1a);
TypedJS.go([test]);
fails with:
Uncaught Error: Parse error on line 1:
//+test1a :: Number -> Numb
-------^
Expecting '::'
Tiny thing, but where it says "Sanity Check your Javascript." it should be JavaScript. Awesome project :)
It's a little late for me so I don't have a good code sample. I'll get one tomorrow.
In the meantime this seems to be failing:
//+ foo: { hello: String } -> String
function foo(o) {
return o.hello;
}
foo({ hello: 'foo', world: 'bar' }); // will fail because world is not typed.
You could make an argument that it should throw a TypeError but I'd like for there to be an option.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.