Skip to content

Commit 73c02eb

Browse files
committed
small fixes
1 parent fca3f39 commit 73c02eb

File tree

7 files changed

+81
-89
lines changed

7 files changed

+81
-89
lines changed

tests/HydraScript.UnitTests/Domain/BackEnd/HashAddressTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void EqualsReturnsFalseForTwoDifferentObjectsWithSameSeed()
1616
}
1717

1818
[Fact]
19-
public void EqualsReturnsTrueForTwoSameOjectsWithSameSeed()
19+
public void EqualsReturnsTrueForTwoSameObjectsWithSameSeed()
2020
{
2121
var address = new HashAddress(1);
2222

tests/HydraScript.UnitTests/Domain/BackEnd/InstructionsData.cs

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,118 +14,118 @@ public class InstructionsData : IEnumerable<object[]>
1414
{
1515
public IEnumerator<object[]> GetEnumerator()
1616
{
17-
yield return new object[]
18-
{
17+
yield return
18+
[
1919
new AsString(new Name("num"))
2020
{
2121
Left = "str"
2222
},
2323
"str = num as string"
24-
};
25-
yield return new object[]
26-
{
24+
];
25+
yield return
26+
[
2727
new BeginBlock(BlockType.Function, blockId: "func")
2828
{
2929
Address = new Label("Start_func")
3030
},
3131
"Start_func:\n\tBeginFunction func"
32-
};
33-
yield return new object[]
34-
{
32+
];
33+
yield return
34+
[
3535
new CallFunction(new FunctionInfo("func"), false),
3636
"Call func"
37-
};
38-
yield return new object[]
39-
{
37+
];
38+
yield return
39+
[
4040
new CallFunction(new FunctionInfo("func"), true)
4141
{
4242
Left = "ret"
4343
},
4444
"ret = Call func"
45-
};
46-
yield return new object[]
47-
{
45+
];
46+
yield return
47+
[
4848
new CreateArray("arr", 5),
4949
"array arr = [5]"
50-
};
51-
yield return new object[]
52-
{
50+
];
51+
yield return
52+
[
5353
new CreateObject("obj"),
5454
"object obj = {}"
55-
};
56-
yield return new object[]
57-
{
55+
];
56+
yield return
57+
[
5858
new DotAssignment("obj", new Constant("prop"), new Constant(3)),
5959
"obj.prop = 3"
60-
};
61-
yield return new object[]
62-
{
60+
];
61+
yield return
62+
[
6363
new EndBlock(BlockType.Function, blockId: "func")
6464
{
6565
Address = new Label("End_func")
6666
},
6767
"End_func:\n\tEndFunction func"
68-
};
69-
yield return new object[]
70-
{
68+
];
69+
yield return
70+
[
7171
new Goto(new Label("10")),
7272
"Goto 10"
73-
};
74-
yield return new object[]
75-
{
73+
];
74+
yield return
75+
[
7676
new Halt(),
7777
"End"
78-
};
79-
yield return new object[]
80-
{
78+
];
79+
yield return
80+
[
8181
new IfNotGoto(new Name("test"), new Label("17")),
8282
"IfNot test Goto 17"
83-
};
84-
yield return new object[]
85-
{
83+
];
84+
yield return
85+
[
8686
new IndexAssignment("arr", new Constant(1), new Constant(1)),
8787
"arr[1] = 1"
88-
};
89-
yield return new object[]
90-
{
88+
];
89+
yield return
90+
[
9191
new Print(new Name("str")),
9292
"Print str"
93-
};
94-
yield return new object[]
95-
{
93+
];
94+
yield return
95+
[
9696
new PushParameter(new Name("value")),
9797
"PushParameter value"
98-
};
99-
yield return new object[]
100-
{
98+
];
99+
yield return
100+
[
101101
new PopParameter("param"),
102102
"PopParameter param"
103-
};
104-
yield return new object[]
105-
{
103+
];
104+
yield return
105+
[
106106
new RemoveFromArray("arr", new Constant(0)),
107107
"RemoveFrom arr at 0"
108-
};
109-
yield return new object[]
110-
{
108+
];
109+
yield return
110+
[
111111
new Return(),
112112
"Return"
113-
};
114-
yield return new object[]
115-
{
113+
];
114+
yield return
115+
[
116116
new Return(new Name("result")),
117117
"Return result"
118-
};
119-
yield return new object[]
120-
{
118+
];
119+
yield return
120+
[
121121
new Simple("a", (new Name("b"), new Name("c")), "+"),
122122
"a = b + c"
123-
};
124-
yield return new object[]
125-
{
123+
];
124+
yield return
125+
[
126126
new Simple("b", (null, new Name("c")), "-"),
127127
"b = -c"
128-
};
128+
];
129129
}
130130

131131
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

tests/HydraScript.UnitTests/Domain/BackEnd/VirtualMachineTests.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ namespace HydraScript.UnitTests.Domain.BackEnd;
1212

1313
public class VirtualMachineTests
1414
{
15-
private readonly IVirtualMachine _vm;
16-
17-
public VirtualMachineTests()
18-
{
19-
_vm = new VirtualMachine(Substitute.For<IOutputWriter>());
20-
}
15+
private readonly VirtualMachine _vm = new(Substitute.For<IOutputWriter>());
2116

2217
[Fact]
2318
public void CorrectPrintToOutTest()
@@ -26,7 +21,7 @@ public void CorrectPrintToOutTest()
2621

2722
var exParams = Substitute.For<IExecuteParams>();
2823
exParams.CallStack.Returns(new Stack<Call>());
29-
exParams.Frames.Returns(new Stack<Frame>(new[] { new Frame(new HashAddress(0)) }));
24+
exParams.Frames.Returns(new Stack<Frame>([new Frame(new HashAddress(0))]));
3025
exParams.Arguments.Returns(new Queue<object?>());
3126
exParams.Writer.Returns(writer);
3227

@@ -153,7 +148,7 @@ public void ObjectCreationTest()
153148
_vm.ExecuteParams.Frames.Pop();
154149
}
155150

156-
public static Halt HaltTrackable()
151+
private static Halt HaltTrackable()
157152
{
158153
var halt = Substitute.For<Halt>();
159154
halt.Execute(default!)

tests/HydraScript.UnitTests/Domain/FrontEnd/ParserData.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ public class ParserSuccessTestData : IEnumerable<object[]>
66
{
77
public IEnumerator<object[]> GetEnumerator()
88
{
9-
yield return new object[] { "-21" };
10-
yield return new object[] { "!false" };
11-
yield return new object[] { "~[]" };
12-
yield return new object[] { "x = ([1,2] ++ [3,4])::0" };
13-
yield return new object[] {"i[0].j"};
14-
yield return new object[] {"i[0].j()"};
15-
yield return new object[] {"i = 1"};
16-
yield return new object[] {"i[0] = 1"};
17-
yield return new object[] {"i[a.b][1].x(1)"};
18-
yield return new object[] {"(1 + 2) * (3 - (2 / 2)) as string"};
19-
yield return new object[] { "return {x:1;y:2;}" };
20-
yield return new object[] { "while (~arr != 0) { arr::0 continue }" };
21-
yield return new object[] { "if (!(true || (false && false))) { break } else { break }" };
9+
yield return ["-21"];
10+
yield return ["!false"];
11+
yield return ["~[]"];
12+
yield return ["x = ([1,2] ++ [3,4])::0"];
13+
yield return ["i[0].j"];
14+
yield return ["i[0].j()"];
15+
yield return ["i = 1"];
16+
yield return ["i[0] = 1"];
17+
yield return ["i[a.b][1].x(1)"];
18+
yield return ["(1 + 2) * (3 - (2 / 2)) as string"];
19+
yield return ["return {x:1;y:2;}"];
20+
yield return ["while (~arr != 0) { arr::0 continue }"];
21+
yield return ["if (!(true || (false && false))) { break } else { break }"];
2222
}
2323

2424
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

tests/HydraScript.UnitTests/Domain/FrontEnd/RegexLexerTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public void EmptyTextTest() =>
3737
[Fact]
3838
public void GetTokensSkipIgnorableTypesTest()
3939
{
40-
const string text = @"
41-
let x = 1 // int
42-
";
40+
const string text = @"let x = 1 // int";
4341
var tokens = _regexLexer.GetTokens(text);
4442
Assert.DoesNotContain(_regexLexer.Structure.FindByTag("Comment"), tokens.Select(x => x.Type));
4543
}

tests/HydraScript.UnitTests/Domain/FrontEnd/TextCoordinateSystemComputerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace HydraScript.UnitTests.Domain.FrontEnd;
55

66
public class TextCoordinateSystemComputerTests
77
{
8-
private ITextCoordinateSystemComputer _sut = new TextCoordinateSystemComputer();
8+
private readonly TextCoordinateSystemComputer _sut = new();
99

1010
[Fact]
1111
public void GetLines_NoNewLine_SingleIndexResult()
@@ -55,7 +55,7 @@ public void GetCoordinates_EmptySystem_StartCoordinatesReturned(IReadOnlyList<in
5555
}
5656

5757
public static TheoryData<IReadOnlyList<int>> EmptySystems =>
58-
new([[], [-1]]);
58+
new([], [-1]);
5959

6060
[Fact]
6161
public void GetCoordinates_NotEmptySystem_CorrectCoordinatesReturned()

tests/HydraScript.UnitTests/Domain/FrontEnd/TopDownParserTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using HydraScript.Domain.FrontEnd.Lexer.Impl;
2-
using HydraScript.Domain.FrontEnd.Parser;
32
using HydraScript.Domain.FrontEnd.Parser.Impl;
43
using HydraScript.Infrastructure;
54

65
namespace HydraScript.UnitTests.Domain.FrontEnd;
76

87
public class TopDownParserTests
98
{
10-
private readonly IParser _parser = new TopDownParser(new RegexLexer(
9+
private readonly TopDownParser _parser = new(new RegexLexer(
1110
new Structure<GeneratedRegexContainer>(new TokenTypesProvider()),
1211
new TextCoordinateSystemComputer()));
1312

0 commit comments

Comments
 (0)