Skip to content

Commit

Permalink
Simplify snapshot test output for export index
Browse files Browse the repository at this point in the history
  • Loading branch information
purefunctor committed Jan 30, 2025
1 parent 6636847 commit 11b4dee
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 299 deletions.
25 changes: 20 additions & 5 deletions crates/indexing/tests/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,33 @@ fn type_role_errors() {

#[test]
fn index_export() {
let (_, index, errors) = index_source(
let (_, index, _) = index_source(
"module Main (life, class Eq, Synonym, Data(..), (+), type (+), module Export) where\n",
);

insta::assert_debug_snapshot!((index, errors));
let life = index.export.lookup_expr_export("life");
let eq_class = index.export.lookup_type_export("Eq");
let synonym = index.export.lookup_type_export("Synonym");
let data = index.export.lookup_type_export("Data");
let plus = index.export.lookup_expr_export("(+)");
let plus_type = index.export.lookup_type_export("(+)");
let export = index.export.lookup_module_export("Export");

let mut snapshot = String::default();
writeln!(snapshot, "life: {:?}", life).unwrap();
writeln!(snapshot, "eq_class: {:?}", eq_class).unwrap();
writeln!(snapshot, "synonym: {:?}", synonym).unwrap();
writeln!(snapshot, "data: {:?}", data).unwrap();
writeln!(snapshot, "plus: {:?}", plus).unwrap();
writeln!(snapshot, "plus_type: {:?}", plus_type).unwrap();
writeln!(snapshot, "export: {:?}", export).unwrap();
insta::assert_snapshot!(snapshot);
}

#[test]
fn index_export_duplicate() {
let (_, index, errors) = index_source(
let (_, _, errors) = index_source(
"module Main (life, life, class Eq, class Eq, Synonym, Synonym, Data(..), Data(..), (+), (+), type (+), type (+), module Export, module Export)"
);

insta::assert_debug_snapshot!((index, errors));
insta::assert_debug_snapshot!(errors);
}
106 changes: 8 additions & 98 deletions crates/indexing/tests/snapshots/indexing__index_export.snap
Original file line number Diff line number Diff line change
@@ -1,102 +1,12 @@
---
source: crates/indexing/tests/indexing.rs
expression: "(index, errors)"
expression: snapshot
snapshot_kind: text
---
(
IndexingResult {
source_map: SourceMap {
exports: {
AstPtr {
raw: SyntaxNodePtr {
kind: ExportValue,
range: 13..17,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportClass,
range: 18..27,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportType,
range: 28..36,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportType,
range: 37..46,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportOperator,
range: 47..51,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportTypeOperator,
range: 52..61,
},
},
AstPtr {
raw: SyntaxNodePtr {
kind: ExportModule,
range: 62..76,
},
},
},
imports: {},
declaration: {},
constructor: {},
class_member: {},
instance: {},
instance_member: {},
},
nominal: NominalIndex {
qualified: {},
expr_item: {},
type_item: {},
},
export: ExportIndex {
module_export: {
"Export": Id(
6,
),
},
expr_export: {
"(+)": Id(
4,
),
"life": Id(
0,
),
},
type_export: {
"(+)": Id(
5,
),
"Synonym": Id(
2,
),
"Eq": Id(
1,
),
"Data": Id(
3,
),
},
},
relational: RelationalIndex {
constructor_of: [],
class_member_of: [],
instance_of: [],
instance_member_of: [],
},
},
[],
)
life: Some(Id(0))
eq_class: Some(Id(1))
synonym: Some(Id(2))
data: Some(Id(3))
plus: Some(Id(4))
plus_type: Some(Id(5))
export: Some(Id(6))
Loading

0 comments on commit 11b4dee

Please sign in to comment.