Commit 3855cfb4a1
Verified · cmc
Layout: unified · split
Tests/OrgCoreTests/EmacsOracle.swift +3 −2
| @@ -162,8 +162,9 @@ func withOptions(_ options: EditingOptions, _ form: String) -> String { | ||
| 162 | 162 | let doomOptions = EditingOptions(tagsColumn: 0, insertHeadingRespectContent: true, metaReturnMaySplitLine: false, listAllowAlphabetical: true, fillColumn: 80, hideEmphasisMarkers: true, prettyEntities: true, subSuperscriptsNeedBraces: true) |
| 163 | 163 | |
| 164 | 164 | /// Runs a command the way an editor would: build a context, run, apply the edits. |
| 165 | func runCommand(_ command: any OrgCommand, _ text: String, caret: Int, answers: [String: String] = [:], options: EditingOptions = .org) -> (text: String, caret: Int, failure: String?) { | |
| 166 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], answers: answers, options: options) | |
| 165 | func runCommand(_ command: any OrgCommand, _ text: String, caret: Int, answers: [String: String] = [:], options: EditingOptions = .org, | |
| 166 | calendar: Calendar = .current) -> (text: String, caret: Int, failure: String?) { | |
| 167 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], calendar: calendar, answers: answers, options: options) | |
| 167 | 168 | switch command.run(in: context) { |
| 168 | 169 | case .commit(let result): |
| 169 | 170 | var new = text |
Tests/OrgCoreTests/SortListTests.swift +8 −1
| @@ -14,6 +14,12 @@ struct SortListTests { | ||
| 14 | 14 | "Intro\n- one\n- two\n continued\n- three\nOutro\n", |
| 15 | 15 | ] |
| 16 | 16 | |
| 17 | static let utc: Calendar = { | |
| 18 | var calendar = Calendar(identifier: .gregorian) | |
| 19 | calendar.timeZone = TimeZone(identifier: "UTC")! | |
| 20 | return calendar | |
| 21 | }() | |
| 22 | ||
| 17 | 23 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) |
| 18 | 24 | func matchesEmacs() throws { |
| 19 | 25 | var cases: [EmacsOracle.Case] = [] |
| @@ -33,7 +39,8 @@ struct SortListTests { | ||
| 33 | 39 | for caret in carets.prefix(2) { |
| 34 | 40 | for key in ["a", "A", "n", "N", "t", "T", "x", "X"] { |
| 35 | 41 | cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: "(org-sort-list nil ?\(key))")) |
| 36 | ours.append(runCommand(SortEntries(), text, caret: caret, answers: ["sort": key])) | |
| 42 | // In UTC, as the oracle runs Emacs: an item without a time sorts as now. | |
| 43 | ours.append(runCommand(SortEntries(), text, caret: caret, answers: ["sort": key], calendar: Self.utc)) | |
| 37 | 44 | } |
| 38 | 45 | } |
| 39 | 46 | } |