Skip to content

Commit

Permalink
final nits
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertp committed Apr 25, 2023
1 parent 85466d2 commit bb80aa9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class WarningBenchmarks extends TestBase {
private Value elemWithWarning;

private OutputStream out = new ByteArrayOutputStream();
private String benchmarkName;

@Setup
public void initializeBench(BenchmarkParams params) throws IOException {
Expand All @@ -55,6 +56,8 @@ public void initializeBench(BenchmarkParams params) throws IOException {
.option("engine.BackgroundCompilation", "true")
.build();

benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");

var code = """
from Standard.Base import all
Expand All @@ -72,12 +75,7 @@ public void initializeBench(BenchmarkParams params) throws IOException {
x = 42
Warning.attach "Foo!" x
""";

var file = File.createTempFile("warnings", ".enso");
try (var w = new FileWriter(file)) {
w.write(code);
}
var src = Source.newBuilder("enso", file).build();
var src = SrcUtil.source(benchmarkName, code);
Value module = ctx.eval(src);
vecSumBench = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "vec_sum_bench"));
createVec = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "create_vec"));
Expand All @@ -87,6 +85,11 @@ public void initializeBench(BenchmarkParams params) throws IOException {
sameWarningVec = createVec.execute(INPUT_VEC_SIZE, elemWithWarning);
}

@TearDown
public void cleanup() {
ctx.close(true);
}

@Benchmark
public void noWarningsVecSum() {
Value res = vecSumBench.execute(noWarningsVec);
Expand Down
5 changes: 5 additions & 0 deletions test/Tests/src/Semantic/Warnings_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ My_Type.my_method self = self.a + self.b + self.c
type Wrap
Value foo

f x _ = Warning.attach "Baz!" x

type My_Fancy_Collection
Value (x:Integer)

Expand Down Expand Up @@ -403,4 +405,7 @@ spec = Test.group "Dataflow Warnings" <|
result_3 = b + b + d
Warning.get_all result_3 . map (x-> x.value.to_text) . should_equal ["Foo!", "Foo!"]

result_4 = f a 1 + f a 2 + f a 3
Warning.get_all result_4 . map (x-> x.value.to_text) . should_equal ["Baz!", "Baz!", "Baz!"]

main = Test_Suite.run_main spec

0 comments on commit bb80aa9

Please sign in to comment.