Skip to content

Commit

Permalink
test: Rename test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Olian04 committed Jun 18, 2024
1 parent 3f75a9c commit d4b9af2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.ez
/build
erl_crash.dump
.DS_Store
18 changes: 9 additions & 9 deletions test/unit_tests/engine_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import handles/ctx
import handles/internal/engine
import handles/internal/parser

pub fn engine_should_return_correct_when_running_hello_world_test() {
pub fn hello_world_test() {
[parser.Constant("Hello World")]
|> engine.run(ctx.Dict([]), string_builder.new())
|> should.be_ok
|> should.equal("Hello World")
}

pub fn engine_should_return_correct_when_running_hello_name_test() {
pub fn hello_name_test() {
[parser.Constant("Hello "), parser.Property(["name"])]
|> engine.run(
ctx.Dict([ctx.Prop("name", ctx.Str("Oliver"))]),
Expand All @@ -21,7 +21,7 @@ pub fn engine_should_return_correct_when_running_hello_name_test() {
|> should.equal("Hello Oliver")
}

pub fn engine_should_return_correct_when_accessing_nested_property_test() {
pub fn nested_property_test() {
[parser.Property(["foo", "bar"])]
|> engine.run(
ctx.Dict([ctx.Prop("foo", ctx.Dict([ctx.Prop("bar", ctx.Int(42))]))]),
Expand All @@ -31,7 +31,7 @@ pub fn engine_should_return_correct_when_accessing_nested_property_test() {
|> should.equal("42")
}

pub fn engine_should_return_correct_when_using_truthy_if_test() {
pub fn truthy_if_test() {
[parser.IfBlock(["bool"], [parser.Property(["foo", "bar"])])]
|> engine.run(
ctx.Dict([
Expand All @@ -44,7 +44,7 @@ pub fn engine_should_return_correct_when_using_truthy_if_test() {
|> should.equal("42")
}

pub fn engine_should_return_correct_when_using_falsy_if_test() {
pub fn falsy_if_test() {
[parser.IfBlock(["bool"], [parser.Property(["foo", "bar"])])]
|> engine.run(
ctx.Dict([ctx.Prop("bool", ctx.Bool(False))]),
Expand All @@ -54,7 +54,7 @@ pub fn engine_should_return_correct_when_using_falsy_if_test() {
|> should.equal("")
}

pub fn engine_should_return_correct_when_using_truthy_unless_test() {
pub fn truthy_unless_test() {
[parser.UnlessBlock(["bool"], [parser.Property(["foo", "bar"])])]
|> engine.run(
ctx.Dict([ctx.Prop("bool", ctx.Bool(True))]),
Expand All @@ -64,7 +64,7 @@ pub fn engine_should_return_correct_when_using_truthy_unless_test() {
|> should.equal("")
}

pub fn engine_should_return_correct_when_using_falsy_unless_test() {
pub fn falsy_unless_test() {
[parser.UnlessBlock(["bool"], [parser.Property(["foo", "bar"])])]
|> engine.run(
ctx.Dict([
Expand All @@ -77,7 +77,7 @@ pub fn engine_should_return_correct_when_using_falsy_unless_test() {
|> should.equal("42")
}

pub fn engine_should_return_correct_when_using_each_test() {
pub fn each_test() {
[
parser.Constant("They are "),
parser.EachBlock(["list"], [
Expand All @@ -103,7 +103,7 @@ pub fn engine_should_return_correct_when_using_each_test() {
|> should.equal("They are Knatte, Fnatte, Tjatte, and Kalle")
}

pub fn engine_should_return_correct_when_using_empty_each_test() {
pub fn empty_each_test() {
[
parser.EachBlock(["list"], [
parser.Property(["name"]),
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/format_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gleeunit/should
import handles/format
import handles/internal/tokenizer

pub fn format_should_return_correct_string_for_unexpected_token_test() {
pub fn unexpected_token_test() {
let template = "{{foo}d"
tokenizer.run(template, 0, [])
|> should.be_error
Expand All @@ -11,7 +11,7 @@ pub fn format_should_return_correct_string_for_unexpected_token_test() {
|> should.equal("Tag is missing closing braces }} (row=0, col=2)")
}

pub fn format_should_return_correct_string_for_unexpected_end_of_template_test() {
pub fn unexpected_end_of_template_test() {
let template = "{{foo}"
tokenizer.run(template, 0, [])
|> should.be_error
Expand Down
12 changes: 6 additions & 6 deletions test/unit_tests/parser_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ import gleeunit/should
import handles/internal/parser
import handles/internal/tokenizer

pub fn parser_should_return_correct_when_compiling_no_tokens_test() {
pub fn no_tokens_test() {
[]
|> parser.run([])
|> should.equal([])
}

pub fn parser_should_return_correct_when_compiling_one_constant_test() {
pub fn one_constant_test() {
[tokenizer.Constant("Hello World")]
|> parser.run([])
|> should.equal([parser.Constant("Hello World")])
}

pub fn parser_should_return_correct_when_compiling_one_property_test() {
pub fn one_property_test() {
[tokenizer.Property(["foo", "bar"])]
|> parser.run([])
|> should.equal([parser.Property(["foo", "bar"])])
}

pub fn parser_should_return_correct_when_compiling_one_ifblock_test() {
pub fn one_ifblock_test() {
[tokenizer.IfBlockStart(["bar", "biz"]), tokenizer.IfBlockEnd]
|> parser.run([])
|> should.equal([parser.IfBlock(["bar", "biz"], [])])
}

pub fn parser_should_return_correct_when_compiling_one_unlessblock_test() {
pub fn one_unlessblock_test() {
[tokenizer.UnlessBlockStart(["bar", "biz"]), tokenizer.UnlessBlockEnd]
|> parser.run([])
|> should.equal([parser.UnlessBlock(["bar", "biz"], [])])
}

pub fn parser_should_return_correct_when_compiling_one_eachblock_test() {
pub fn one_eachblock_test() {
[tokenizer.EachBlockStart(["bar", "biz"]), tokenizer.EachBlockEnd]
|> parser.run([])
|> should.equal([parser.EachBlock(["bar", "biz"], [])])
Expand Down
16 changes: 8 additions & 8 deletions test/unit_tests/tokenizer_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import gleeunit/should
import handles/error
import handles/internal/tokenizer

pub fn tokenizer_should_return_correct_when_parsing_empty_string_test() {
pub fn empty_string_test() {
""
|> tokenizer.run(0, [])
|> should.be_ok
|> should.equal([])
}

pub fn tokenizer_should_return_correct_when_passed_one_tag_test() {
pub fn one_tag_test() {
"{{foo}}"
|> tokenizer.run(0, [])
|> should.be_ok
|> should.equal([tokenizer.Property(["foo"])])
}

pub fn tokenizer_should_return_correct_when_passed_two_tags_test() {
pub fn two_tags_test() {
"{{foo}} {{bar}}"
|> tokenizer.run(0, [])
|> should.be_ok
Expand All @@ -27,35 +27,35 @@ pub fn tokenizer_should_return_correct_when_passed_two_tags_test() {
])
}

pub fn tokenizer_should_return_lex_error_when_unexpected_token_test() {
pub fn unexpected_token_test() {
"{{foo}d"
|> tokenizer.run(0, [])
|> should.be_error
|> should.equal(error.UnbalancedTag(2))
}

pub fn tokenizer_should_return_lex_error_when_unexpected_end_of_template_test() {
pub fn unexpected_end_of_template_test() {
"{{foo}"
|> tokenizer.run(0, [])
|> should.be_error
|> should.equal(error.UnbalancedTag(2))
}

pub fn compiler_should_return_error_when_missing_block_kind_test() {
pub fn missing_block_argument_test() {
"{{#if}}"
|> tokenizer.run(0, [])
|> should.be_error
|> should.equal(error.MissingBlockArgument(2))
}

pub fn compiler_should_return_error_when_providing_arguments_to_end_block_test() {
pub fn end_block_with_arguments_test() {
"{{/if bar}}"
|> tokenizer.run(0, [])
|> should.be_error
|> should.equal(error.UnexpectedBlockArgument(2))
}

pub fn compiler_should_return_error_when_providing_empty_expression_test() {
pub fn empty_expression_test() {
"{{}}"
|> tokenizer.run(0, [])
|> should.be_error
Expand Down
6 changes: 3 additions & 3 deletions test/user_stories/hello_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const expected_ast = [

const expected_output = "Hello Oliver!"

pub fn tokenizer_should_return_correct_for_user_story_helloworld_test() {
pub fn tokenizer_test() {
tokenizer.run(input_template, 0, [])
|> should.be_ok
|> should.equal(expected_tokens)
}

pub fn parser_should_return_correct_for_user_story_helloworld_test() {
pub fn parser_test() {
parser.run(expected_tokens, [])
|> should.equal(expected_ast)
}

pub fn engine_should_return_correct_for_user_story_helloworld_test() {
pub fn engine_test() {
engine.run(expected_ast, input_context, string_builder.new())
|> should.be_ok
|> should.equal(expected_output)
Expand Down
6 changes: 3 additions & 3 deletions test/user_stories/knattarna_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ const expected_ast = [

const expected_output = "They are Knatte, Fnatte, Tjatte, and Kalle"

pub fn tokenizer_should_return_correct_for_user_story_knattarna_test() {
pub fn tokenizer_test() {
tokenizer.run(input_template, 0, [])
|> should.be_ok
|> should.equal(expected_tokens)
}

pub fn parser_should_return_correct_for_user_story_knattarna_test() {
pub fn parser_test() {
parser.run(expected_tokens, [])
|> should.equal(expected_ast)
}

pub fn engine_should_return_correct_for_user_story_knattarna_test() {
pub fn engine_test() {
engine.run(expected_ast, input_context, string_builder.new())
|> should.be_ok
|> should.equal(expected_output)
Expand Down
6 changes: 3 additions & 3 deletions test/user_stories/nested_block.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ const expected_ast = [

const expected_output = "1212"

pub fn tokenizer_should_return_correct_for_user_story_nested_test() {
pub fn tokenizer_test() {
tokenizer.run(input_template, 0, [])
|> should.be_ok
|> should.equal(expected_tokens)
}

pub fn parser_should_return_correct_for_user_story_nested_test() {
pub fn parser_test() {
parser.run(expected_tokens, [])
|> should.equal(expected_ast)
}

pub fn engine_should_return_correct_for_user_story_nested_test() {
pub fn engine_test() {
engine.run(expected_ast, input_context, string_builder.new())
|> should.be_ok
|> should.equal(expected_output)
Expand Down

0 comments on commit d4b9af2

Please sign in to comment.