Skip to content

Conversation

@Chemaclass
Copy link
Member

📚 Description

Related to: phpstan/phpstan-src#3160 (comment)

The \n are ignored when counting the lines actual=$(echo "$input_str" | wc -l | tr -d '[:blank:]')

🔖 Changes

  • Count additionally the \n of a string on assert_line_count
Comment on lines +328 to +329
actual=$(echo "$input_str" | wc -l | tr -d '[:blank:]')
additional_new_lines=$(grep -o '\\n' <<< "$input_str" | wc -l | tr -d '[:blank:]')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why/how bash represents the newline in 2 different characters.. but the tests seem to show it works.

I don't know why 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here... I just got to this solution driven by the tests, I don't understand why this works... so it's bash... 🤣

And here, yet, another proof that TDD works 😝

@Chemaclass Chemaclass requested a review from staabm June 17, 2024 21:33
@Chemaclass Chemaclass merged commit 775c8de into main Jun 17, 2024
@Chemaclass Chemaclass deleted the fix/assert-line-count branch June 17, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

4 participants