use of com.googlecode.jslint4java.Util.Converter in project jslint4java by happygiraffe.
the class UtilTest method testListValueOfObject.
@Test
public void testListValueOfObject() throws Exception {
cx.evaluateString(scope, "var l = [{'a':1}, {'a':2}];", "-", 1, null);
Util.Converter<Foo> c = new Converter<Foo>() {
public Foo convert(Object obj) {
Scriptable scope = (Scriptable) obj;
return new Foo((int) Context.toNumber(scope.get("a", scope)));
}
};
List<Foo> l = Util.listValue("l", scope, c);
assertThat(l, contains(new Foo(1), new Foo(2)));
}
Aggregations