Skip to content

Commit

Permalink
fix: broken tests
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <[email protected]>
  • Loading branch information
azjezz committed Dec 7, 2024
1 parent 3d8e551 commit 889eda1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 41 deletions.
2 changes: 1 addition & 1 deletion crates/fixer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ mod tests {
let content = "The quick brown fox jumps over the lazy dog.";
let mut fix = FixPlan::new();
fix.delete(10..19, SafetyClassification::Safe); // Delete "brown fox"
fix.replace(16..19, "cat", SafetyClassification::Safe); // Replace "fox" (which is partially deleted)
fix.insert(16, "cat", SafetyClassification::Safe); // Replace "fox" (which is partially deleted)
let result = fix.execute(content);
assert_eq!(result.get_fixed(), "The quick cat jumps over the lazy dog.");
// "brown fox" deleted, "cat" inserted
Expand Down
10 changes: 5 additions & 5 deletions crates/lexer/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<'a> Input<'a> {
/// use mago_lexer::input::Input;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let source = SourceIdentifier::dummy();
///
/// // Given input "( string ) x", starting at offset 0:
/// let input = Input::new(source.clone(), b"( string ) x");
Expand Down Expand Up @@ -411,19 +411,19 @@ mod tests {

// '\r\n' should be treated as one newline
input.next();
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 5));
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 4));

// 'c'
input.next();
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 6));
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 5));

// '\r'
input.next();
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 7));
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 6));

// 'd'
input.next();
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 8));
assert_eq!(input.position(), Position::new(SourceIdentifier::dummy(), 7));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a, 'i> Lexer<'a, 'i> {
///
/// let interner = ThreadedInterner::new();
///
/// let source = SourceIdentifier::empty();
/// let source = SourceIdentifier::dummy();
/// let input = Input::new(source, b"<?php echo 'Hello, World!'; ?>");
///
/// let mut lexer = Lexer::new(&interner, input);
Expand Down
58 changes: 24 additions & 34 deletions crates/reporting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ impl Annotation {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Annotation, AnnotationKind};
/// use mago_reporting::{Annotation, AnnotationKind};
/// use mago_span::Span;
/// use mago_span::Position;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let start = Position::new(source, 0, 0, 0);
/// let end = Position::new(source, 0, 0, 5);
/// let start = Position::dummy(0);
/// let end = Position::dummy(5);
/// let span = Span::new(start, end);
/// let annotation = Annotation::new(AnnotationKind::Primary, span);
/// ```
Expand All @@ -104,14 +102,12 @@ impl Annotation {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Annotation, AnnotationKind};
/// use mago_reporting::{Annotation, AnnotationKind};
/// use mago_span::Span;
/// use mago_span::Position;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let start = Position::new(source, 0, 0, 0);
/// let end = Position::new(source, 0, 0, 5);
/// let start = Position::dummy(0);
/// let end = Position::dummy(5);
/// let span = Span::new(start, end);
/// let annotation = Annotation::primary(span);
/// ```
Expand All @@ -124,14 +120,12 @@ impl Annotation {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Annotation, AnnotationKind};
/// use mago_reporting::{Annotation, AnnotationKind};
/// use mago_span::Span;
/// use mago_span::Position;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let start = Position::new(source, 0, 0, 0);
/// let end = Position::new(source, 0, 0, 5);
/// let start = Position::dummy(0);
/// let end = Position::dummy(5);
/// let span = Span::new(start, end);
/// let annotation = Annotation::secondary(span);
/// ```
Expand All @@ -144,14 +138,12 @@ impl Annotation {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Annotation, AnnotationKind};
/// use mago_reporting::{Annotation, AnnotationKind};
/// use mago_span::Span;
/// use mago_span::Position;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let start = Position::new(source, 0, 0, 0);
/// let end = Position::new(source, 0, 0, 5);
/// let start = Position::dummy(0);
/// let end = Position::dummy(5);
/// let span = Span::new(start, end);
/// let annotation = Annotation::primary(span).with_message("This is a primary annotation");
/// ```
Expand All @@ -169,7 +161,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Issue, Level};
/// use mago_reporting::{Issue, Level};
///
/// let issue = Issue::new(Level::Error, "This is an error");
/// ```
Expand All @@ -191,7 +183,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::error("This is an error");
/// ```
Expand All @@ -204,7 +196,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::warning("This is a warning");
/// ```
Expand All @@ -217,7 +209,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::help("This is a help message");
/// ```
Expand All @@ -230,7 +222,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::note("This is a note");
/// ```
Expand All @@ -243,7 +235,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Issue, Level};
/// use mago_reporting::{Issue, Level};
///
/// let issue = Issue::error("This is an error").with_code("E0001");
/// ```
Expand All @@ -259,14 +251,12 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::{Issue, Annotation, AnnotationKind};
/// use mago_reporting::{Issue, Annotation, AnnotationKind};
/// use mago_span::Span;
/// use mago_span::Position;
/// use mago_source::SourceIdentifier;
///
/// let source = SourceIdentifier::empty();
/// let start = Position::new(source, 0, 0, 0);
/// let end = Position::new(source, 0, 0, 5);
/// let start = Position::dummy(0);
/// let end = Position::dummy(5);
/// let span = Span::new(start, end);
///
/// let issue = Issue::error("This is an error").with_annotation(Annotation::primary(span));
Expand All @@ -290,7 +280,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::error("This is an error").with_note("This is a note");
/// ```
Expand All @@ -308,7 +298,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::error("This is an error").with_help("This is a help message");
/// ```
Expand All @@ -324,7 +314,7 @@ impl Issue {
/// # Examples
///
/// ```
/// use mago_reporting::issue::Issue;
/// use mago_reporting::Issue;
///
/// let issue = Issue::error("This is an error").with_link("https://example.com");
/// ```
Expand Down

0 comments on commit 889eda1

Please sign in to comment.