Closed scitesy closed 13 years ago
Hey, the source code looks very mangled, can you paste it somewhere it doesn't get squashed? (Github Gist, paste2.org, etc.)
So I managed to debug it, the problem is that the "setTimeout" function doesn't exist in IronJS (as it's not part of the ECMA spec) and when you do this:
var original = base[name]; if (original.apply) { }
original is undefined, since base[name] really is base["setTimeout"], which really is jasmine.getGlobal()["setTimeout"], which really just is the global setTimeout variable, which is undefined. And when you try to access .apply on undefined an exception is thrown, and this is in compliance with the ECMA3 spec, the if test should be:
if(typeof original !== "undefined" && original.apply) {
}
I know the error is a bit cryptic and doesn't give much information, I'm working on improving that :)
Thanks so much for looking into this! Sorry about the poor formatting. Next time I'll create a gist/paste bin and link it.
No problem! Just happy people are reporting issues so I can look into, and possibly fix them :)
Is there any plane to implement setTimeout/setInterval?
@flechto, there are no plans at this time to implement any browser-specific items in IronJS. That being said, this would be an easy thing for anyone using IronJS to implement themselves.
The last line in the code block is the failure point. In the Jasmine library itself it is lines 62-65 that are failing. Please let me know if you need anymore information.
StackTrace: Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> IronJS.UserError: Error: at Microsoft.FSharp.Core.Operators.Raise[T](Exception exn) at IronJS.Environment.RaiseError[g](CommonObject prototype, String message) in C:\cygwin\home\scitess\code\IronJS\Src\IronJS\Core.fs:line 419 at IronJS.Environment.RaiseTypeError[c](String message) in C:\cygwin\home\scitess\code\IronJS\Src\IronJS\Core.fs:line 431 at IronJS.Environment.RaiseTypeError[c]() in C:\cygwin\home\scitess\code\IronJS\Src\IronJS\Core.fs:line 430 at IronJS.TypeConverter.ToObject(Environment env, BoxedValue v) in C:\cygwin\home\scitess\code\IronJS\Src\IronJS\Core.fs:line 2040 at lambda_method(Closure , FunctionObject , CommonObject , BoxedValue , String ) at IronJS.FunctionObject.Call[a,b](CommonObject this, a a, b b) in C:\cygwin\home\scitess\code\IronJS\Src\IronJS\Core.fs:line 1604 at lambda_method(Closure , FunctionObject , CommonObject ) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
Code: var jasmine = {};
jasmine.getGlobal = function() { function getGlobal() { return this; } return getGlobal(); };
jasmine.bindOriginal_ = function(base, name) { var original = base[name]; if (original.apply) { return function() { return original.apply(base, arguments); }; } else { return jasmine.getGlobal()[name]; } };
jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');