Lab Report 5 - Week 10
More Debugging w/ Large Code Bases
Yoooooo, this is the fifth and final lab report for CSE 15L! There isn’t nothing special this time around about debugging, but it’s more about the specifics of debugging and making it more versatile.
Within debugging, there’s a lot more useful things to make testing your code more convenient. In this case, we could use scripts and using vim to have more control to our code & tests.
Using vimdiff
If we have two separate programs which do the same function, how do we compare the results when we are dealing with a huuuuge amount of tests & files? Surely you aren’t going to look at each file one by one…? That’s going to take forever, so to compare how two programs’ results of the same function, we can use a vim
command!
The command I used to find the different results of two MarkdownParse
programs (mine & lab 9’s) is vimdiff
, where I compared two text files with one and another to see if the results match or are different!
-
My
results.txt
-
Lab 9’s
results.txt
The specific command I used for vimdiff
is:
vimdiff my-markdown-parser/results.txt markdown-parser-lab9/results.txt
- The first
results.txt
is comparing a file within my markdown directory - The second
results.txt
is comparing a file within lab 9’s markdown directory
Test 421
For the test case #421, using vimdiff
, here are the results:
- The left is my markdown & the right is lab 9’s markdown (open the image in a new tab to see better!)
- My markdown resulted in
[]
- Lab 9’s markdown resulted in
[/url]
- My markdown resulted in
The test file for #421 is:
**foo [bar](/url)**
-
Looking at the link, it looks like the output should result in
[/url]
- It looks like lab 9’s implementation of a markdown parser was correct
- While my markdown parser was not successful
So what was wrong with my implementation?
- I think the core bug with my implementation is that my
MarkdownParse
looks for actual and real valid link that would work realistically. So when it parsed through the test file of #421, it saw/url
as a link, but not a valid link. If I were to fix my Markdown, I would probably deal with the code that checks actual valid links.
Test 194
For test case #194, using vimdiff
, the results are:
- The left is my markdown & the right is lab 9’s markdown (open the image in a new tab to see better!)
- My markdown resulted in
[]
- Lab 9’s markdown resulted in
[url]
- My markdown resulted in
The test file for #194 is:
[Foo*bar\]]:my_(url) 'title (with parens)'
[Foo*bar\]]
-
Just looking at this file, it clearly looks like the output should result in
[]
- Thus, I can conclude that lab 9’s implementation was wrong
- While my markdown parser was right
So what went wrong compared to my markdown and lab 9’s markdown implementation?
- I believe that the bug that overall came about with lab 9’s is that they didn’t acknowledge the overlapping syntaxes that would consider the link to be invalid. In the markdown preview, it does show that it works, but just looking at the test file, it clearly should not work if there are a ton of weird syntaxes that counteract the syntax for a link. I’m not sure about a fix for lab 9’s markdown, but a suggestion would be to check the overlapping syntax formatting issues first before checking the actual link.
Conclusion
To sum it up, there is no perfect MarkdownParse
, where each one has its advantages than others (includes weaknesses & flaws). For the most part, my MarkdownParse
had a huge difference than lab 9’s MarkdownParse
due to my code checking if it is an actual & real valid link, while lab 9 does not check for syntax issues. Either way, if it works, it works.
Shoutout to the amazing TAs & the Prof himself for making the course interesting and neat! While sometimes I felt that some weeks were a hassle, I overall enjoyed the course. Until next time folks!