From f9e330349f1aec43d80ef2f4c57d0868ed397168 Mon Sep 17 00:00:00 2001 From: Andrea Alberti Date: Fri, 16 Aug 2024 17:23:04 +0200 Subject: [PATCH] Finished with the dynamic parser --- src/generateParser.ts | 5 ++++- tests/unit/FlashcardReviewSequencer.test.ts | 13 +++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/generateParser.ts b/src/generateParser.ts index 7d572497..8c0eed95 100644 --- a/src/generateParser.ts +++ b/src/generateParser.ts @@ -8,11 +8,14 @@ let oldOptions: ParserOptions; export function generateParser(options: ParserOptions): Parser { - // if the parser existed already and the user provided the same options, we simply reuse the already generated parser if(parser && areParserOptionsEqual(options,oldOptions)) { + // If the parser existed already and the user provided the same options, + // we simply reuse the already generated parser return parser; } + /* GENERATE A NEW PARSER */ + oldOptions = copyParserOptions(options); const close_rules_list: string[] = []; diff --git a/tests/unit/FlashcardReviewSequencer.test.ts b/tests/unit/FlashcardReviewSequencer.test.ts index 42498533..5bcf37a8 100644 --- a/tests/unit/FlashcardReviewSequencer.test.ts +++ b/tests/unit/FlashcardReviewSequencer.test.ts @@ -101,7 +101,6 @@ class TestContext { text: string, fakeFilePath?: string, ): TestContext { - let cardSequencer: IDeckTreeIterator = new DeckTreeIterator(iteratorOrder, null); let noteEaseList = new NoteEaseList(settings); let cardScheduleCalculator: CardScheduleCalculator = new CardScheduleCalculator( @@ -759,7 +758,6 @@ describe("updateCurrentQuestionText", () => { describe("Checking update to file", () => { describe("Single line card type; Settings - schedule on following line", () => { - test("Question has schedule on following line before/after update", async () => { let text: string = ` #flashcards Q1::A1 @@ -804,7 +802,7 @@ describe("updateCurrentQuestionText", () => { ); }); }); - + describe("Single line card type; Settings - schedule on same line", () => { let settings: SRSettings = { ...DEFAULT_SETTINGS }; settings.cardCommentOnSameLine = true; @@ -991,13 +989,13 @@ ${updatedQuestionText}`; ); }); - // DISABLED TEST. IT SEEMS UNNECESSARY TO TRIM THE END OF LINES /*test("Question starts line after tag (single space after tag before newline); New card", async () => { + test("Question starts line after tag (single space after tag before newline); New card", async () => { let originalQuestionStr: string = `#flashcards${space} Q2 ? -A2 helloooooo`; +A2`; let fileText: string = ` ${originalQuestionStr} @@ -1022,12 +1020,11 @@ ${updatedQuestionText}`; expectedUpdatedStr, DEFAULT_SETTINGS, ); - }); - });*/ + });*/ + }); }); }); - describe("getDeckStats", () => { describe("Single level deck with some new and due cards", () => { test("Initial stats", async () => {