jasmine.Suite() required error

1,172 views
Skip to first unread message

James Martin

unread,
Oct 12, 2010, 11:30:28 AM10/12/10
to Jasmine
Hi,

I'm trying to use Jasmine from within the Titanium Appcelerator
framework.

Attempting to run a very simple test throws this error inside
jasmine.Env.prototype.describe...


Error: jasmine.Suite() required at jasmine.js...


My spec looks like this:

describe("Some Simple Test", function() {

it("should fail", function() {
return false;
});

});


Given that the 'it' is wrapped in a 'describe' block, I would expect
that the specDefinitions.call(suite) should not throw an error.

I've checked the values of the arguments to 'describe()' and each of
the important looking bits throughout that function, and everything
looks fine up to this point:

var declarationError = null;
try {
specDefinitions.call(suite);
} catch(e) {
declarationError = e;
}

The error is being thrown from inside the
'specDefinitions.call(suite)'

Any ideas?


Thanks,
James.

James Martin

unread,
Oct 12, 2010, 12:27:03 PM10/12/10
to Jasmine
I figured out what was going on and it was my own stupid fault
(shock)....

In order to get Jasmine running inside the whatever JVM Titanium runs
in I had to change the getter for Env, from this:

return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();

To this...

if(jasmine.currentEnv_ == null) {
return jasmine.currentEnv_ = new jasmine.Env();
}
else {
return jasmine.currentEnv_;
};

It's somewhat ugly, but at least it compiles. If I can get the rest of
it working, would you consider taking a patch for this at some point?

Now to figure out how to get the results!


Thanks,
James.



Rajan Agaskar

unread,
Oct 12, 2010, 12:31:21 PM10/12/10
to jasmi...@googlegroups.com
Does this imply that null is considered true in the JVM Titanium interpreter?

What is the result of something like

foo = null || 1

We could make this change, but I think we use this sort of default pattern in a lot of places, so it might be a lot of complexity to support something that seems like weird interpreter behavior. ..

Thanks!

Rajan



Thanks,
James.



--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To post to this group, send email to jasmi...@googlegroups.com.
To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.


James Martin

unread,
Oct 12, 2010, 1:43:12 PM10/12/10
to Jasmine
On Oct 12, 5:31 pm, Rajan Agaskar <ra...@pivotallabs.com> wrote:
> Does this imply that null is considered true in the JVM Titanium
> interpreter?
>
> What is the result of something like
>
> foo = null || 1
>

Somewhat confusingly, foo == 1 in this interpreter.

James Martin

unread,
Oct 12, 2010, 1:48:03 PM10/12/10
to Jasmine
Incidentally, the warnings from the interpreter with the original code
were:

[WARN] JavaScript compiler reported "Expected an identifier and
instead saw '='." at lib/jasmine-1.0.0/jasmine.js:115
[WARN] JavaScript compiler reported "Stopping, unable to continue. (4%
scanned)." at lib/jasmine-1.0.0/jasmine.js:115


Thanks,
James.

Rajan Agaskar

unread,
Oct 12, 2010, 1:50:35 PM10/12/10
to jasmi...@googlegroups.com
huh, wonder if it's a weird assignment order thing?

What does

(function() {
return foo = null || 1;
};)()

return?


--

James Martin

unread,
Oct 13, 2010, 10:00:18 AM10/13/10
to Jasmine
On Oct 12, 6:50 pm, Rajan Agaskar <ra...@pivotallabs.com> wrote:
> huh, wonder if it's a weird assignment order thing?
>
> What does
>
> (function() {
> return foo = null || 1;
>
> };)()
>
> return?
>

That produces the same parse error as in jasmine.getEnv.

I've forked jasmine and made a change (not quite as ugly) to base.js,
which appears to pass the existing specs and still works in the
Titanium iPhone JVM. Here's the commit:

http://github.com/RiverGlide/jasmine/commit/11573292a5d70f1831adc3e0dfe5c9823e066458


Thanks,
James.

Rajan Agaskar

unread,
Oct 13, 2010, 10:24:48 AM10/13/10
to jasmi...@googlegroups.com
 How about

  (function() {
  return (foo = null || 1);

  };)()

If we can get it working for you by just enclosing the statement in parens, I think that's a win.

Thanks!

Rajan



--

James Martin

unread,
Oct 13, 2010, 11:45:43 AM10/13/10
to Jasmine
On Oct 13, 3:24 pm, Rajan Agaskar <ra...@pivotallabs.com> wrote:
>  How about
>
>   (function() {
>   return (foo = null || 1);
>
>   };)()
>
> If we can get it working for you by just enclosing the statement in parens,
> I think that's a win.

Interesting. This works:

return (jasmine.currentEnv_ = jasmine.currentEnv_ || new
jasmine.Env());

From a readability perspective, I prefer the version in my previous
post, as it makes the check implicit, however, it's a matter of style
so I'd be happy with whichever change you feel is best for Jasmine.


Thanks,
James.
Reply all
Reply to author
Forward
0 new messages