Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniform alignment of strings #126

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,48 @@ class CommentedCodeCheckTest extends MagikCheckTestBase {
@ValueSource(
strings = {
"""
_method a.b
_method a.b
_local x << _self.call()
x +<< 10
write(x)
_return x
_endmethod
""",
_endmethod
""",
"""
_method a.b
_method a.b
# This is
# just a
# message,
# no real.
# code.
_endmethod
""",
_endmethod
""",
"""
_method a.b
_method a.b
a # z
b # y
c # x
_endmethod
""",
_endmethod
""",
"""
_method a.b
_method a.b
## print(1)
## print(2)
## print(3)
## print(4)
print(1)
_endmethod
""",
_endmethod
""",
"""
# Author : Me
# Date written : 01/95
# Date changed :
""",
# Author : Me
# Date written : 01/95
# Date changed :
""",
"""
#
# Add/Remove
#
""",
#
# Add/Remove
#
""",
})
void testValid(final String code) {
final MagikCheck check = new CommentedCodeCheck();
Expand All @@ -70,10 +70,10 @@ void testValid(final String code) {
strings = {
"""
_method a.b
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
_endmethod
""",
"""
Expand All @@ -99,21 +99,21 @@ void testValid(final String code) {
// This will mark the indented commented body.
"""
#_method a.b
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
#_endmethod
""",
"""
#_method a.b
#_local x << _self.call()
#x +<< 10
#x *<< 2
#
#write(x)
#x -<< 5
#_return x
#_local x << _self.call()
#x +<< 10
#x *<< 2
#
#write(x)
#x -<< 5
#_return x
#_endmethod
""",
})
Expand All @@ -129,16 +129,17 @@ void testInvalid2() {
final String code =
"""
_method a.b
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
_return 10
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
_endmethod""";
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
_return 10
#_local x << _self.call()
#x +<< 10
#write(x)
#_return x
_endmethod
""";
final List<MagikIssue> issues = this.runCheck(code, check);
assertThat(issues).hasSize(2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ class EmptyBlockCheckTest extends MagikCheckTestBase {
strings = {
"""
_block
write(a)
write(a)
_endblock
""",
"""
_if a
_then
write(a)
write(a)
_endif
""",
"""
_if a
_then
write(a)
write(a)
_elif b
_then
write(b)
write(b)
_endif
""",
"""
_if a
_then
write(a)
_else
write(b)
_endif
""",
_if a
_then
write(a)
_else
write(b)
_endif
""",
"""
_abstract _method a.b
_endmethod
Expand All @@ -68,27 +68,27 @@ void testValid(final String code) {
"""
_if a
_then
write(a)
write(a)
_elif b
_then
_endif
""",
"""
_if a
_then
write(a)
write(a)
_else
_endif
""",
"""
_protect
_protection
write(a)
write(a)
_endprotect
""",
"""
_protect
write(a)
write(a)
_protection
_endprotect
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void testMaxSlotCountSatisfied() {
final String code =
"""
def_slotted_exemplar(:exemplar, {
{:slot_1, _unset}})
{:slot_1, _unset}})
""";
final List<MagikIssue> issues = this.runCheck(code, check);
assertThat(issues).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void testParentOk() {
final String code =
"""
def_slotted_exemplar(
:test_exemplar,
{})""";
:test_exemplar,
{})""";
final List<MagikIssue> issues = this.runCheck(code, check);
assertThat(issues).isEmpty();
}
Expand All @@ -29,9 +29,9 @@ void testParentForbidden() {
final String code =
"""
def_slotted_exemplar(
:test_exemplar,
{},
:rwo_record)""";
:test_exemplar,
{},
:rwo_record)""";
final List<MagikIssue> issues = this.runCheck(code, check);
assertThat(issues).hasSize(1);
}
Expand All @@ -43,9 +43,9 @@ void testParentForbidden2() {
final String code =
"""
def_slotted_exemplar(
:test_exemplar,
{},
{@sw:rwo_record})""";
:test_exemplar,
{},
{@sw:rwo_record})""";
final List<MagikIssue> issues = this.runCheck(code, check);
assertThat(issues).hasSize(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class FormattingCheckTest extends MagikCheckTestBase {
""",
"""
show( # comment
param1)""",
param1)
""",
})
void testProper(final String code) {
final MagikCheck check = new FormattingCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ class HidesVariableCheckTest extends MagikCheckTestBase {
@ValueSource(
strings = {
"""
_block
_local a << 10
_block
_local a << 10
_block
_local b << 20
_endblock
_local b << 20
_endblock
""",
_endblock
""",
"""
_block
_local a << 10
_proc()
_import a
_endproc
_endblock
""",
_block
_local a << 10
_proc()
_import a
_endproc
_endblock
""",
"""
_block
_block
_block
_local a << 20
_endblock
_local a << 10
_local a << 20
_endblock
""",
_local a << 10
_endblock
""",
})
void testValid(final String code) {
final MagikCheck check = new HidesVariableCheck();
Expand All @@ -49,45 +49,45 @@ void testValid(final String code) {
@ValueSource(
strings = {
"""
_block
_local a << 10
_block
_local a << 10
_block
_local a << 20
_endblock
_local a << 20
_endblock
""",
_endblock
""",
"""
_block
_local a << 10, b << 20
_block
_local a << 10, b << 20
_block
_local a << 20
_endblock
_local a << 20
_endblock
""",
_endblock
""",
"""
_block
_local a << 10
_block
_local a << 10
_block
_local b << 20, a << 30
_endblock
_local b << 20, a << 30
_endblock
""",
_endblock
""",
"""
_block
_local (a, b) << (10, 20)
_block
_local (a, b) << (10, 20)
_block
_local a << 20
_endblock
_local a << 20
_endblock
""",
_endblock
""",
"""
_block
_local a << 10
_block
_local a << 10
_block
_local (b, a) << (20, 30)
_endblock
_local (b, a) << (20, 30)
_endblock
""",
_endblock
""",
})
void testInvalid(final String code) {
final MagikCheck check = new HidesVariableCheck();
Expand Down
Loading
Loading