I have read numerous times that Hosted mode tests bytecode, while Web
mode tests in actual JavaScript.   Wanting to delve into this deeper,
I came up with the following, in which the JUnit tests succeed in both
hosted and web modes.  I was expecting that because I used native JS
features not available in Java, it would fail in hosted mode:

package com.x.gwt.firsttest.client;

public class StringProducer {
          public native String getSomeText()/*-{
              String.prototype.yo = function() {
                  return "Hello there";
          };
          return "Yo".yo();
          }-*/;

}

And then the test class:

package com.x.gwt.firsttest.client;

import com.google.gwt.junit.client.GWTTestCase;

public class FirstTest extends GWTTestCase {

  public String getModuleName() {
    return "com.x.gwt.firsttest.FirstApp";
  }

  public void testStringProducer() {
          assertEquals("Hello there", new StringProducer().getSomeText());
  }

}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to