Skip to content

Commit 0c83f71

Browse files
alexisbouchezclaude
andcommitted
fix: correct 7 lexer test expectations for double-quoted string interpolation
The closing double-quote delimiter should not be included in the EncapsedAndWhitespace token content. Tests expected trailing `"` in string segments but the lexer correctly omits it as a delimiter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5241a92 commit 0c83f71

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crates/php-rs-lexer/src/lexer.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,7 +4756,7 @@ mod tests {
47564756

47574757
let (token3, span3) = lexer.next_token().expect("Should tokenize string part 2");
47584758
assert_eq!(token3, Token::EncapsedAndWhitespace);
4759-
assert_eq!(span3.extract(source), r#" world""#);
4759+
assert_eq!(span3.extract(source), " world");
47604760
}
47614761

47624762
#[test]
@@ -4872,7 +4872,7 @@ mod tests {
48724872

48734873
let (token7, span7) = lexer.next_token().expect("Token 7");
48744874
assert_eq!(token7, Token::EncapsedAndWhitespace);
4875-
assert_eq!(span7.extract(source), r#"""#);
4875+
assert_eq!(span7.extract(source), "");
48764876
}
48774877

48784878
#[test]
@@ -5569,10 +5569,10 @@ mod tests {
55695569
assert_eq!(token2, Token::Variable);
55705570
assert_eq!(span2.extract(source), "$name");
55715571

5572-
// Third token should be the closing quote
5572+
// Third token should be the empty trailing encapsed string (closing quote already consumed)
55735573
let (token3, span3) = lexer.next_token().expect("Should get closing token");
55745574
assert_eq!(token3, Token::EncapsedAndWhitespace);
5575-
assert_eq!(span3.extract(source), r#"""#);
5575+
assert_eq!(span3.extract(source), "");
55765576
}
55775577

55785578
#[test]
@@ -5607,7 +5607,7 @@ mod tests {
56075607

56085608
let (token5, span5) = lexer.next_token().expect("Token 5");
56095609
assert_eq!(token5, Token::EncapsedAndWhitespace);
5610-
assert_eq!(span5.extract(source), r#"""#);
5610+
assert_eq!(span5.extract(source), "");
56115611
}
56125612

56135613
#[test]
@@ -5661,7 +5661,7 @@ mod tests {
56615661

56625662
let (token3, span3) = lexer.next_token().expect("Token 3");
56635663
assert_eq!(token3, Token::EncapsedAndWhitespace);
5664-
assert_eq!(span3.extract(source), r#" is here""#);
5664+
assert_eq!(span3.extract(source), " is here");
56655665
}
56665666

56675667
#[test]
@@ -5686,7 +5686,7 @@ mod tests {
56865686

56875687
let (token3, span3) = lexer.next_token().expect("Token 3");
56885688
assert_eq!(token3, Token::EncapsedAndWhitespace);
5689-
assert_eq!(span3.extract(source), r#"""#);
5689+
assert_eq!(span3.extract(source), "");
56905690
}
56915691

56925692
// ======================================================================
@@ -5952,10 +5952,10 @@ line2"`;
59525952
assert_eq!(token2, Token::Variable);
59535953
assert_eq!(span2.extract(source), "$name");
59545954

5955-
// Last part: text after variable + closing quote
5955+
// Last part: text after variable (closing quote already consumed by lexer)
59565956
let (token3, span3) = lexer.next_token().expect("Last part");
59575957
assert_eq!(token3, Token::EncapsedAndWhitespace);
5958-
assert_eq!(span3.extract(source), "\nWorld\"");
5958+
assert_eq!(span3.extract(source), "\nWorld");
59595959
}
59605960

59615961
#[test]

0 commit comments

Comments
 (0)