Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java

Issue 29348972: Issue 4239 - Change indentation to reflect our coding style (Closed)
Patch Set: Created Aug. 2, 2016, 10:43 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java
index c2f63941dcec6f2b796eb28739ae2f4269daacce..bdca799a9e4bcb23e871541a8e5ce3402549268e 100644
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/JsTest.java
@@ -27,230 +27,231 @@ import java.util.List;
public class JsTest extends BaseJsTest
{
- @Test
- public void testUndefinedValue()
+ @Test
+ public void testUndefinedValue()
+ {
+ final JsValue value = jsEngine.evaluate("undefined");
+ assertTrue(value.isUndefined());
+ assertFalse(value.isNull());
+ assertFalse(value.isString());
+ assertFalse(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertFalse(value.isObject());
+ assertFalse(value.isArray());
+ assertEquals("undefined", value.asString());
+ try
{
- final JsValue value = jsEngine.evaluate("undefined");
- assertTrue(value.isUndefined());
- assertFalse(value.isNull());
- assertFalse(value.isString());
- assertFalse(value.isBoolean());
- assertFalse(value.isNumber());
- assertFalse(value.isObject());
- assertFalse(value.isArray());
- assertEquals("undefined", value.asString());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- try
- {
- value.getProperty("foo");
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
}
-
- @Test
- public void testNullValue()
+ try
+ {
+ value.getProperty("foo");
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
{
- final JsValue value = jsEngine.evaluate("null");
- assertFalse(value.isUndefined());
- assertTrue(value.isNull());
- assertFalse(value.isString());
- assertFalse(value.isBoolean());
- assertFalse(value.isNumber());
- assertFalse(value.isObject());
- assertFalse(value.isArray());
- assertFalse(value.isFunction());
- assertEquals("null", value.asString());
- assertFalse(value.asBoolean());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- try
- {
- value.getProperty("foo");
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
+ // ignored
}
+ }
- @Test
- public void testStringValue()
+ @Test
+ public void testNullValue()
+ {
+ final JsValue value = jsEngine.evaluate("null");
+ assertFalse(value.isUndefined());
+ assertTrue(value.isNull());
+ assertFalse(value.isString());
+ assertFalse(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertFalse(value.isObject());
+ assertFalse(value.isArray());
+ assertFalse(value.isFunction());
+ assertEquals("null", value.asString());
+ assertFalse(value.asBoolean());
+ try
{
- JsValue value = jsEngine.evaluate("'123'");
- assertFalse(value.isUndefined());
- assertFalse(value.isNull());
- assertTrue(value.isString());
- assertFalse(value.isBoolean());
- assertFalse(value.isNumber());
- assertFalse(value.isObject());
- assertFalse(value.isArray());
- assertFalse(value.isFunction());
- assertEquals("123", value.asString());
- assertEquals(123l, value.asLong());
- assertTrue(value.asBoolean());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- try
- {
- value.getProperty("foo");
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
}
-
- @Test
- public void testLongValue()
+ try
+ {
+ value.getProperty("foo");
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
{
- JsValue value = jsEngine.evaluate("12345678901234");
- assertFalse(value.isUndefined());
- assertFalse(value.isNull());
- assertFalse(value.isString());
- assertFalse(value.isBoolean());
- assertTrue(value.isNumber());
- assertFalse(value.isObject());
- assertFalse(value.isArray());
- assertFalse(value.isFunction());
- assertEquals("12345678901234", value.asString());
- assertEquals(12345678901234l, value.asLong());
- assertTrue(value.asBoolean());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- try {
- value.getProperty("foo");
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
+ // ignored
}
+ }
- @Test
- public void testBoolValue()
+ @Test
+ public void testStringValue()
+ {
+ JsValue value = jsEngine.evaluate("'123'");
+ assertFalse(value.isUndefined());
+ assertFalse(value.isNull());
+ assertTrue(value.isString());
+ assertFalse(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertFalse(value.isObject());
+ assertFalse(value.isArray());
+ assertFalse(value.isFunction());
+ assertEquals("123", value.asString());
+ assertEquals(123l, value.asLong());
+ assertTrue(value.asBoolean());
+ try
{
- JsValue value = jsEngine.evaluate("true");
- assertFalse(value.isUndefined());
- assertFalse(value.isNull());
- assertFalse(value.isString());
- assertTrue(value.isBoolean());
- assertFalse(value.isNumber());
- assertFalse(value.isObject());
- assertFalse(value.isArray());
- assertFalse(value.isFunction());
- assertEquals("true", value.asString());
- assertTrue(value.asBoolean());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- try
- {
- value.getProperty("foo");
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
}
-
- @Test
- public void testObjectValue()
+ try
+ {
+ value.getProperty("foo");
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
{
- final String source =
- "function Foo() {\n" +
- " this.x = 2;\n" +
- " this.toString = function() {return 'foo';};\n" +
- " this.valueOf = function() {return 123;};\n" +
- "};\n" +
- "new Foo()";
- JsValue value = jsEngine.evaluate(source);
- assertFalse(value.isUndefined());
- assertFalse(value.isNull());
- assertFalse(value.isString());
- assertFalse(value.isBoolean());
- assertFalse(value.isNumber());
- assertTrue(value.isObject());
- assertFalse(value.isArray());
- assertFalse(value.isFunction());
- assertEquals("foo", value.asString());
- assertEquals(123l, value.asLong());
- assertTrue(value.asBoolean());
- try
- {
- value.asList();
- fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
- } catch (AdblockPlusException e)
- {
- // ignored
- }
- assertEquals(2l, value.getProperty("x").asLong());
+ // ignored
}
+ }
- @Test
- public void testArrayValue()
+ @Test
+ public void testLongValue()
+ {
+ JsValue value = jsEngine.evaluate("12345678901234");
+ assertFalse(value.isUndefined());
+ assertFalse(value.isNull());
+ assertFalse(value.isString());
+ assertFalse(value.isBoolean());
+ assertTrue(value.isNumber());
+ assertFalse(value.isObject());
+ assertFalse(value.isArray());
+ assertFalse(value.isFunction());
+ assertEquals("12345678901234", value.asString());
+ assertEquals(12345678901234l, value.asLong());
+ assertTrue(value.asBoolean());
+ try
{
- JsValue value = jsEngine.evaluate("[5,8,12]");
- assertFalse(value.isUndefined());
- assertFalse(value.isNull());
- assertFalse(value.isString());
- assertFalse(value.isBoolean());
- assertFalse(value.isNumber());
- assertTrue(value.isObject());
- assertTrue(value.isArray());
- assertEquals("5,8,12", value.asString());
- assertTrue(value.asBoolean());
- assertEquals(3l, value.asList().size());
- assertEquals(5l, value.asList().get(0).asLong());
- assertEquals(8l, value.asList().get(1).asLong());
- assertEquals(12l, value.asList().get(2).asLong());
- assertEquals(3l, value.getProperty("length").asLong());
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
}
+ try
+ {
+ value.getProperty("foo");
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
+ }
+ }
- @Test
- public void testThrowingCoversion()
+ @Test
+ public void testBoolValue()
+ {
+ JsValue value = jsEngine.evaluate("true");
+ assertFalse(value.isUndefined());
+ assertFalse(value.isNull());
+ assertFalse(value.isString());
+ assertTrue(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertFalse(value.isObject());
+ assertFalse(value.isArray());
+ assertFalse(value.isFunction());
+ assertEquals("true", value.asString());
+ assertTrue(value.asBoolean());
+ try
+ {
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
+ }
+ try
+ {
+ value.getProperty("foo");
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
{
- final String source =
- "function Foo() {\n" +
- " this.toString = function() {throw 'test1';};\n" +
- " this.valueOf = function() {throw 'test2';};\n" +
- "};\n" +
- "new Foo()";
+ // ignored
+ }
+ }
- JsValue value = jsEngine.evaluate(source);
- assertEquals("", value.asString());
- assertEquals(0l, value.asLong());
+ @Test
+ public void testObjectValue()
+ {
+ final String source =
+ "function Foo() {\n" +
+ " this.x = 2;\n" +
+ " this.toString = function() {return 'foo';};\n" +
+ " this.valueOf = function() {return 123;};\n" +
+ "};\n" +
+ "new Foo()";
+ JsValue value = jsEngine.evaluate(source);
+ assertFalse(value.isUndefined());
+ assertFalse(value.isNull());
+ assertFalse(value.isString());
+ assertFalse(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertTrue(value.isObject());
+ assertFalse(value.isArray());
+ assertFalse(value.isFunction());
+ assertEquals("foo", value.asString());
+ assertEquals(123l, value.asLong());
+ assertTrue(value.asBoolean());
+ try
+ {
+ value.asList();
+ fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
+ } catch (AdblockPlusException e)
+ {
+ // ignored
}
+ assertEquals(2l, value.getProperty("x").asLong());
+ }
+
+ @Test
+ public void testArrayValue()
+ {
+ JsValue value = jsEngine.evaluate("[5,8,12]");
+ assertFalse(value.isUndefined());
+ assertFalse(value.isNull());
+ assertFalse(value.isString());
+ assertFalse(value.isBoolean());
+ assertFalse(value.isNumber());
+ assertTrue(value.isObject());
+ assertTrue(value.isArray());
+ assertEquals("5,8,12", value.asString());
+ assertTrue(value.asBoolean());
+ assertEquals(3l, value.asList().size());
+ assertEquals(5l, value.asList().get(0).asLong());
+ assertEquals(8l, value.asList().get(1).asLong());
+ assertEquals(12l, value.asList().get(2).asLong());
+ assertEquals(3l, value.getProperty("length").asLong());
+ }
+
+ @Test
+ public void testThrowingCoversion()
+ {
+ final String source =
+ "function Foo() {\n" +
+ " this.toString = function() {throw 'test1';};\n" +
+ " this.valueOf = function() {throw 'test2';};\n" +
+ "};\n" +
+ "new Foo()";
+
+ JsValue value = jsEngine.evaluate(source);
+ assertEquals("", value.asString());
+ assertEquals(0l, value.asLong());
+ }
}

Powered by Google App Engine
This is Rietveld