Skip to content

Commit ab9f87c

Browse files
Happypig375FoggyFindercharlesroddie
authored
Parser refactor (part 1) (#143)
* LaTeXParser now uses Result * CI passing? * nullables are now errors * Eliminate a nullability error * WIP refactor in progress * Finished porting AtomForCommand over * Stop Commands should be able to be ported now * Ported Stop Commands * Trie * Moved commands up * Be more linent w.r.t. slow VMs * See the time * Now we optimize it * Trie optimized * Optimizations again * Trie removal * Generalized trie * Trie iterate * \atopwithdelims * Correct implementation of \rm and friends * Fix test * Fixed \sqrt[3} * Fix \TeX * Using the trie * Optimize trie lookup * Update dotnet * Simplify Result * Fix comments * Add comment range tests * Apply suggestions from code review Co-authored-by: FoggyFinder <[email protected]> * Document a bit * Rename kern -> skip * Revert AngouriUpdate * Fix types * remove unused methods prior to reviewing ProxyAdder * hygiene: remove "add" optional function inside BiDictionary (breaks build) * builds * simplify * remove some unused BiDictionary methods and fix implementations of remaining methods * remove unused MultiDictionary * remove commented code * Add doc and TODO about doc * further BiDictionary simplification * finished reviewing bidictionary * correct RemoveByFirst * correct RemoveByFirst * Fix BiDictionary initialization (messy; awaiting LaTeXCommandDictionary documentation for further cleanup) * fix BiDictionary initialization * fix bidicitonary initializastion * remove class constraint on TFirst * Remove unused LaTeXCommandDictionary properties * prune and document LaTeXCommandDictionary * Remove Trie * remove Trie pt 2 * Fix casing as ReadOnlySpan.StartsWithInvariant seems to be case insentitive * document asymmetric RemoveByFirst/Second approach * Add dictionary remove tests * revert latexsettings.cs * revert latexsettings * rename added * Document LaTeXCommandDictionary * restore a test * tweaks * tweaks * tweaks * tweaks * Remove CopyTo as it is not used and BiDictionary doesn't implement ICollection * Added an unused method but this is bad practice * stringcomparison.ordinal to fix test * another ordinal * "AliasBiDictionary" * Fix a method reference * Find longest non-command * tidy concatenation * Use (string Command, TValue Value) * apply automatic refactor * remove i * Simplify SortedSet * fix build * shorten * local functions * Update CSharpMath/Structures/Dictionary.cs Co-authored-by: Hadrian Tang <[email protected]> * string * suppressmessage * csharp syntax * Update justification * Use more documentation tags * Update test description * Clarify words * Apply suggested change Co-authored-by: FoggyFinder <[email protected]> Co-authored-by: FoggyFinder <[email protected]> Co-authored-by: Charles Roddie <[email protected]> Co-authored-by: Charles Roddie <[email protected]>
1 parent d835e93 commit ab9f87c

File tree

61 files changed

+1998
-2006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1998
-2006
lines changed

.github/workflows/Test all projects.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup .NET Core
1515
uses: actions/setup-dotnet@v1
1616
with:
17-
dotnet-version: '3.1.201'
17+
dotnet-version: '3.1.301'
1818
- name: Setup JDK # Needed to run ANTLR for AngouriMath
1919
uses: actions/setup-java@v1
2020
with:

CSharpMath.CoreTests/BiDictionaryTests.cs

-73
This file was deleted.
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Xunit;
2+
using CSharpMath.Structures;
3+
4+
namespace CSharpMath.CoreTests {
5+
public class DictionaryTests {
6+
private AliasBiDictionary<string, int> InitTestDict() {
7+
return new AliasBiDictionary<string, int>{
8+
{ "0", 0 },
9+
{ "zero", 0 },
10+
{ "1", 1 }
11+
};
12+
}
13+
[Theory]
14+
[InlineData("0", 2, 2, true)]
15+
[InlineData("zero", 2, 2, true)]
16+
[InlineData("1", 2, 1, true)]
17+
[InlineData("2", 3, 2, false)]
18+
public void TestRemoveByFirst(string remove, int expectedFTS, int expectedSTF, bool expectedRemoved) {
19+
var bd = InitTestDict();
20+
var removed = bd.RemoveByFirst(remove);
21+
Assert.Equal(expectedFTS, bd.FirstToSecond.Count);
22+
Assert.Equal(expectedSTF, bd.SecondToFirst.Count);
23+
Assert.Equal(expectedRemoved, removed);
24+
}
25+
[Theory]
26+
[InlineData(0, 1, 1, true)]
27+
[InlineData(1, 2, 1, true)]
28+
[InlineData(2, 3, 2, false)]
29+
public void TestRemoveBySecond(int remove, int expectedFTS, int expectedSTF, bool expectedRemoved) {
30+
var bd = InitTestDict();
31+
var removed = bd.RemoveBySecond(remove);
32+
Assert.Equal(expectedFTS, bd.FirstToSecond.Count);
33+
Assert.Equal(expectedSTF, bd.SecondToFirst.Count);
34+
Assert.Equal(expectedRemoved, removed);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)