From ab69cd22e91d4525a63bdddb2a83afcb9785b138 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Thu, 9 May 2024 15:43:07 +0200 Subject: [PATCH] Make ohd files use LF ending for cross-platform spans --- ohdlc/.gitattributes | 1 + ohdlc/tests/basic.ohd | 2 + ohdlc/tests/snapshots/basic__main.snap | 544 ------------------ ...asic__main-2.snap => basic__main.snap.new} | 59 +- 4 files changed, 33 insertions(+), 573 deletions(-) create mode 100644 ohdlc/.gitattributes delete mode 100644 ohdlc/tests/snapshots/basic__main.snap rename ohdlc/tests/snapshots/{basic__main-2.snap => basic__main.snap.new} (80%) diff --git a/ohdlc/.gitattributes b/ohdlc/.gitattributes new file mode 100644 index 0000000..8e51b06 --- /dev/null +++ b/ohdlc/.gitattributes @@ -0,0 +1 @@ +*.ohd text eol=lf \ No newline at end of file diff --git a/ohdlc/tests/basic.ohd b/ohdlc/tests/basic.ohd index b0a2403..4eadffa 100644 --- a/ohdlc/tests/basic.ohd +++ b/ohdlc/tests/basic.ohd @@ -1,3 +1,5 @@ +// MAKE SURE TO SAFE IN `LF` + mod std { enum Logical { High, diff --git a/ohdlc/tests/snapshots/basic__main.snap b/ohdlc/tests/snapshots/basic__main.snap deleted file mode 100644 index e5aae6d..0000000 --- a/ohdlc/tests/snapshots/basic__main.snap +++ /dev/null @@ -1,544 +0,0 @@ ---- -source: tests/basic.rs -expression: root ---- -[ - Module( - Module { - name: `std`:4..7, - items: [ - Enum( - Enum { - name: `Logical`:20..27, - variants: [ - `High`:39..43, - `Low`:54..57, - ], - }, - ):15..68, - ], - }, - ):0..73, - Use( - Use { - path: Path( - [ - PathSegment( - `std`:76..79, - ), - PathSegment( - `Logical`:81..88, - ), - ], - Root, - ):74..89, - }, - ):70..96, - Module( - Module { - name: `x`:97..98, - items: [ - Use( - Use { - path: Path( - [ - PathSegment( - `y`:110..111, - ), - ], - Local, - ):110..112, - }, - ):106..115, - ], - }, - ):93..122, - Module( - Module { - name: `y`:123..124, - items: [ - Use( - Use { - path: Path( - [ - PathSegment( - `x`:136..137, - ), - ], - Local, - ):136..138, - }, - ):132..141, - ], - }, - ):119..151, - Record( - Record { - name: `MyRecord`:152..160, - fields: [ - Field { - name: `a`:168..169, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:171..178, - ), - ], - Local, - ):171..179, - }:171..179, - }:168..179, - Field { - name: `b`:185..186, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:188..195, - ), - ], - Local, - ):188..196, - }:188..196, - }:185..196, - ], - }, - ):145..207, - Enum( - Enum { - name: `MyEnum`:208..214, - variants: [ - `A`:222..223, - `B`:230..231, - `C`:238..239, - `D`:246..247, - `E`:254..255, - ], - }, - ):203..269, - Entity( - Entity { - name: `HalfAdder`:270..279, - ports: [ - Port { - kind: Input:287..289, - name: `a`:291..292, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:294..301, - ), - ], - Local, - ):294..302, - }:294..302, - }:287..302, - Port { - kind: Input:308..310, - name: `b`:312..313, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:315..322, - ), - ], - Local, - ):315..323, - }:315..323, - }:308..323, - Port { - kind: Output:329..332, - name: `o`:333..334, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:336..343, - ), - ], - Local, - ):336..344, - }:336..344, - }:329..344, - Port { - kind: Output:350..353, - name: `c`:354..355, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:357..364, - ), - ], - Local, - ):357..365, - }:357..365, - }:350..365, - ], - }, - ):263..376, - Arch( - Arch { - name: `RTL`:377..380, - ty: Type { - path: Path( - [ - PathSegment( - `HalfAdder`:385..394, - ), - ], - Local, - ):385..396, - }:385..396, - stmts: [ - Assign( - AssignStmt { - assignee: `o`:402..403, - value: Binary { - left: Primary( - `a`:407..408, - ), - right: Primary( - `b`:413..414, - ), - operator: Xor, - }, - }, - ):402..422, - Assign( - AssignStmt { - assignee: `c`:421..422, - value: Binary { - left: Primary( - `a`:426..427, - ), - right: Primary( - `b`:432..433, - ), - operator: And, - }, - }, - ):421..437, - ], - }, - ):372..444, - Use( - Use { - path: Path( - [ - PathSegment( - `a`:445..446, - ), - PathSegment( - `b`:448..449, - ), - PathSegment( - `Lol`:451..454, - ), - ], - Local, - ):445..455, - }, - ):441..462, - Module( - Module { - name: `a`:463..464, - items: [ - Use( - Use { - path: Path( - [ - PathSegment( - `other`:476..481, - ), - PathSegment( - `b`:483..484, - ), - ], - Local, - ):476..485, - }, - ):472..488, - ], - }, - ):459..495, - Module( - Module { - name: `other`:496..501, - items: [ - Module( - Module { - name: `b`:513..514, - items: [ - Entity( - Entity { - name: `Lol`:533..536, - ports: [], - }, - ):526..547, - ], - }, - ):509..550, - ], - }, - ):492..560, - Entity( - Entity { - name: `FullAdder`:561..570, - ports: [ - Port { - kind: Input:578..580, - name: `a`:582..583, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:585..592, - ), - ], - Local, - ):585..593, - }:585..593, - }:578..593, - Port { - kind: Input:599..601, - name: `b`:603..604, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:606..613, - ), - ], - Local, - ):606..614, - }:606..614, - }:599..614, - Port { - kind: Input:620..622, - name: `ci`:624..626, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:628..635, - ), - ], - Local, - ):628..636, - }:628..636, - }:620..636, - Port { - kind: Output:642..645, - name: `o`:646..647, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:649..656, - ), - ], - Local, - ):649..657, - }:649..657, - }:642..657, - Port { - kind: Output:663..666, - name: `co`:667..669, - ty: Type { - path: Path( - [ - PathSegment( - `Logical`:671..678, - ), - ], - Local, - ):671..679, - }:671..679, - }:663..679, - ], - }, - ):554..690, - Arch( - Arch { - name: `RTL`:691..694, - ty: Type { - path: Path( - [ - PathSegment( - `FullAdder`:699..708, - ), - ], - Local, - ):699..710, - }:699..710, - stmts: [ - Place( - PlaceStmt { - entity_ty: Type { - path: Path( - [ - PathSegment( - `HalfAdder`:716..725, - ), - ], - Local, - ):716..726, - }:716..726, - arch_ty: Type { - path: Path( - [ - PathSegment( - `RTL`:726..729, - ), - ], - Local, - ):726..730, - }:726..730, - links: [ - PlaceLink { - src: `a`:742..743, - arrow_span: Span( - 744, - 746, - ), - link: Ingoing( - Primary( - `a`:747..748, - ):747..749, - ), - }:742..749, - PlaceLink { - src: `b`:759..760, - arrow_span: Span( - 761, - 763, - ), - link: Ingoing( - Primary( - `b`:764..765, - ):764..766, - ), - }:759..766, - PlaceLink { - src: `o`:776..777, - arrow_span: Span( - 778, - 780, - ), - link: Outgoing( - NewSignal( - `s`:788..789, - ):781..790, - ), - }:776..790, - PlaceLink { - src: `c`:800..801, - arrow_span: Span( - 802, - 804, - ), - link: Outgoing( - NewSignal( - `cb`:812..814, - ):805..815, - ), - }:800..815, - ], - }, - ):716..839, - Place( - PlaceStmt { - entity_ty: Type { - path: Path( - [ - PathSegment( - `HalfAdder`:830..839, - ), - ], - Local, - ):830..840, - }:830..840, - arch_ty: Type { - path: Path( - [ - PathSegment( - `RTL`:840..843, - ), - ], - Local, - ):840..844, - }:840..844, - links: [ - PlaceLink { - src: `a`:856..857, - arrow_span: Span( - 858, - 860, - ), - link: Ingoing( - Primary( - `s`:861..862, - ):861..863, - ), - }:856..863, - PlaceLink { - src: `b`:873..874, - arrow_span: Span( - 875, - 877, - ), - link: Ingoing( - Primary( - `ci`:878..880, - ):878..881, - ), - }:873..881, - PlaceLink { - src: `o`:891..892, - arrow_span: Span( - 893, - 895, - ), - link: Outgoing( - Ref( - `o`:896..897, - ):896..898, - ), - }:891..898, - PlaceLink { - src: `c`:908..909, - arrow_span: Span( - 910, - 912, - ), - link: Outgoing( - NewSignal( - `cc`:920..922, - ):913..923, - ), - }:908..923, - ], - }, - ):830..940, - Assign( - AssignStmt { - assignee: `co`:938..940, - value: Binary { - left: Primary( - `cb`:944..946, - ), - right: Primary( - `cc`:950..952, - ), - operator: Or, - }, - }, - ):938..956, - ], - }, - ):686..956, -] diff --git a/ohdlc/tests/snapshots/basic__main-2.snap b/ohdlc/tests/snapshots/basic__main.snap.new similarity index 80% rename from ohdlc/tests/snapshots/basic__main-2.snap rename to ohdlc/tests/snapshots/basic__main.snap.new index 5b06fef..36105e3 100644 --- a/ohdlc/tests/snapshots/basic__main-2.snap +++ b/ohdlc/tests/snapshots/basic__main.snap.new @@ -1,5 +1,6 @@ --- source: tests/basic.rs +assertion_line: 90 expression: refined_types --- Registry { @@ -15,7 +16,7 @@ Registry { ModuleId( 1, ): Module { - name: `x`:97..98, + name: `x`:89..90, scope: ScopeId( 2, ), @@ -23,7 +24,7 @@ Registry { ModuleId( 2, ): Module { - name: `y`:123..124, + name: `y`:111..112, scope: ScopeId( 3, ), @@ -31,7 +32,7 @@ Registry { ModuleId( 3, ): Module { - name: `a`:463..464, + name: `a`:420..421, scope: ScopeId( 4, ), @@ -39,7 +40,7 @@ Registry { ModuleId( 4, ): Module { - name: `other`:496..501, + name: `other`:449..454, scope: ScopeId( 5, ), @@ -47,7 +48,7 @@ Registry { ModuleId( 5, ): Module { - name: `b`:513..514, + name: `b`:465..466, scope: ScopeId( 6, ), @@ -61,13 +62,13 @@ Registry { type_id: TypeId( 0, ), - name: `Logical`:20..27, + name: `Logical`:19..26, variants: [ Variant { - ident: `High`:39..43, + ident: `High`:37..41, }, Variant { - ident: `Low`:54..57, + ident: `Low`:51..54, }, ], }, @@ -79,10 +80,10 @@ Registry { type_id: TypeId( 1, ), - name: `MyRecord`:152..160, + name: `MyRecord`:136..144, fields: [ Field { - name: `a`:168..169, + name: `a`:151..152, ty: Some( TypeId( 0, @@ -90,7 +91,7 @@ Registry { ), }, Field { - name: `b`:185..186, + name: `b`:167..168, ty: Some( TypeId( 0, @@ -107,22 +108,22 @@ Registry { type_id: TypeId( 2, ), - name: `MyEnum`:208..214, + name: `MyEnum`:187..193, variants: [ Variant { - ident: `A`:222..223, + ident: `A`:200..201, }, Variant { - ident: `B`:230..231, + ident: `B`:207..208, }, Variant { - ident: `C`:238..239, + ident: `C`:214..215, }, Variant { - ident: `D`:246..247, + ident: `D`:221..222, }, Variant { - ident: `E`:254..255, + ident: `E`:228..229, }, ], }, @@ -134,11 +135,11 @@ Registry { type_id: TypeId( 3, ), - name: `HalfAdder`:270..279, + name: `HalfAdder`:241..250, ports: [ Port { kind: Input, - name: `a`:291..292, + name: `a`:261..262, ty: Some( TypeId( 0, @@ -147,7 +148,7 @@ Registry { }, Port { kind: Input, - name: `b`:312..313, + name: `b`:281..282, ty: Some( TypeId( 0, @@ -156,7 +157,7 @@ Registry { }, Port { kind: Output, - name: `o`:333..334, + name: `o`:301..302, ty: Some( TypeId( 0, @@ -165,7 +166,7 @@ Registry { }, Port { kind: Output, - name: `c`:354..355, + name: `c`:321..322, ty: Some( TypeId( 0, @@ -182,7 +183,7 @@ Registry { type_id: TypeId( 4, ), - name: `Lol`:533..536, + name: `Lol`:484..487, ports: [], }, ), @@ -193,11 +194,11 @@ Registry { type_id: TypeId( 5, ), - name: `FullAdder`:561..570, + name: `FullAdder`:508..517, ports: [ Port { kind: Input, - name: `a`:582..583, + name: `a`:528..529, ty: Some( TypeId( 0, @@ -206,7 +207,7 @@ Registry { }, Port { kind: Input, - name: `b`:603..604, + name: `b`:548..549, ty: Some( TypeId( 0, @@ -215,7 +216,7 @@ Registry { }, Port { kind: Input, - name: `ci`:624..626, + name: `ci`:568..570, ty: Some( TypeId( 0, @@ -224,7 +225,7 @@ Registry { }, Port { kind: Output, - name: `o`:646..647, + name: `o`:589..590, ty: Some( TypeId( 0, @@ -233,7 +234,7 @@ Registry { }, Port { kind: Output, - name: `co`:667..669, + name: `co`:609..611, ty: Some( TypeId( 0,