Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
  • Loading branch information
Licenser committed Feb 17, 2021
1 parent ddc5409 commit 1bf1124
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 26 deletions.
2 changes: 2 additions & 0 deletions tests/query_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ test_cases!(
pp_embed_unrecognized_token4,
pp_embed_unrecognized_token5,
//INSERT
aggr_arity,
aggr_in_aggr,
bad_into,
bad_from,
node_duplicate_name_operator,
Expand Down
3 changes: 3 additions & 0 deletions tests/query_errors/aggr_arity/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error:
1 | select aggr::stats::sum(event, 1, 2, 3) from in into out;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bad arity for function stats::sum/1..=1 but was called with 4 arguments
1 change: 1 addition & 0 deletions tests/query_errors/aggr_arity/query.trickle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select aggr::stats::sum(event, 1, 2, 3) from in into out;
3 changes: 3 additions & 0 deletions tests/query_errors/aggr_in_aggr/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error:
1 | select aggr::stats::sum(aggr::stats::sum(event)) from in into out;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Aggregates can not be called inside of aggregates
1 change: 1 addition & 0 deletions tests/query_errors/aggr_in_aggr/query.trickle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select aggr::stats::sum(aggr::stats::sum(event)) from in into out;
5 changes: 5 additions & 0 deletions tests/query_errors/new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ cp -r ${BASEDIR}/_template ${TARGET}
git add ${TARGET}

sed -e "s;//INSERT;//INSERT\n ${NAME},;" ${BASEDIR}/../query_error.rs > ${BASEDIR}/tmp && mv ${BASEDIR}/tmp ${BASEDIR}/../query_error.rs

for f in ${TARGET}/*
do
echo "$f"
done
1 change: 1 addition & 0 deletions tests/script_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ test_cases!(
pp_cyclic,
pp_nest_cyclic,
//INSERT
missing_function,
string_interpolation_empty,
fn_bad_recur,
script_without_newline,
Expand Down
6 changes: 6 additions & 0 deletions tests/script_errors/missing_function/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error:
3 | 42
4 | end;
5 | end;
6 | snot::badger(event)
| ^^^^^^^^^^^^^^^^^^^ Call to undefined function snot::badger
6 changes: 6 additions & 0 deletions tests/script_errors/missing_function/script.tremor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod snot with
fn boo() with
42
end;
end;
snot::badger(event)
2 changes: 1 addition & 1 deletion tests/script_errors/new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ sed -e '/^ \/\/INSERT/a\
for f in ${TARGET}/*
do
echo "$f"
done
done
36 changes: 11 additions & 25 deletions tremor-script/src/ast/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2149,32 +2149,18 @@ impl<'script> Upable<'script> for LocalPathRaw<'script> {
let id = helper.meta.name_dflt(mid).to_string();
let mid = helper.add_meta_w_name(self.start, self.end, &id);

// NOTE We never modularise `window`, `args` or `group`
//
let mut rel_path = if id != "args" && id != "window" && id != "group" {
helper.module.clone()
} else {
vec![]
};
let mut rel_path = helper.module.clone();
rel_path.push(id.to_string());
#[allow(clippy::option_if_let_else)]
// we cannot use map_or_else here because of the borrow checker
if let Some(idx) = helper.is_const(&rel_path) {
Ok(LocalPath {
is_const: true,
idx: *idx,
mid,
segments,
})
} else {
let idx = helper.var_id(&id);
Ok(LocalPath {
is_const: false,
idx,
mid,
segments,
})
}
let (idx, is_const) = helper
.is_const(&rel_path)
.copied()
.map_or_else(|| (helper.var_id(&id), false), |idx| (idx, true));
Ok(LocalPath {
is_const,
idx,
mid,
segments,
})
} else {
// We should never encounter this
error_oops(
Expand Down

0 comments on commit 1bf1124

Please sign in to comment.