Skip to content

Commit

Permalink
feat(objectionary#329): enable 'streams' integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jul 11, 2024
1 parent 72d4a11 commit 59a043b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/it/streams/src/main/java/org/eolang/streams/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

public class Main {
public static void main(String... args) {
// long start = System.currentTimeMillis();
long start = System.currentTimeMillis();
String[] strings = IntStream.range(0, 10)
.mapToObj(i -> String.valueOf(i))
.toArray(String[]::new);
// int sum = Arrays.stream(strings)
// .filter(s -> Boolean.valueOf(s.equals("")).equals(false))
// .mapToInt(s -> Integer.parseInt(s))
// .sum();
// System.out.printf("sum=%d time=%d\n", sum, System.currentTimeMillis() - start);
int sum = Arrays.stream(strings)
.filter(s -> Boolean.valueOf(s.equals("")).equals(false))
.mapToInt(s -> Integer.parseInt(s))
.sum();
System.out.printf("sum=%d time=%d\n", sum, System.currentTimeMillis() - start);
}
}
35 changes: 16 additions & 19 deletions src/main/java/org/eolang/opeo/ast/CheckCast.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,6 @@ public CheckCast(final XmlNode node, final Parser parser) {
this(CheckCast.xtype(node), CheckCast.xvalue(node, parser));
}

private static AstNode xvalue(final XmlNode node, final Parser parser) {
return parser.parse(
node.children().collect(Collectors.toList()).get(1)
);
}

private static Type xtype(final XmlNode node) {
return Type.getType(
new HexString(
node.children().findFirst().orElseThrow(
() -> new IllegalArgumentException(
"CheckCast should have a first child for the type."
)
).text()
).decode()
);
}


public CheckCast(final Type type, final AstNode value) {
this.type = type;
this.value = value;
Expand All @@ -99,4 +80,20 @@ public List<AstNode> opcodes() {
public Type type() {
return this.type;
}

private static AstNode xvalue(final XmlNode node, final Parser parser) {
return parser.parse(node.children().collect(Collectors.toList()).get(1));
}

private static Type xtype(final XmlNode node) {
return Type.getType(
new HexString(
node.children().findFirst().orElseThrow(
() -> new IllegalArgumentException(
"CheckCast should have a first child for the type."
)
).text()
).decode()
);
}
}

0 comments on commit 59a043b

Please sign in to comment.