Maybe Test::LongString's most common function is contains_string(), which you may know as Test::WWW::Mechanize's $mech->content_contains() method. When it fails, the failing test output shows the original string and the text it was trying to find:
# searched: "foo bar"
# can't find: "baz"
Problem is, when the original string is too long, you get only the beginning of it. This happens a lot when you're trying to find content inside HTML, like:
# searched: "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Trans"...
# can't find: "some random content"
Such output is only barely useful, and I got fed up of having to edit a test file manually, add diag() calls to see the complete output, then ack for the wanted string to see what went wrong. So I made a small patch to Test::LongString, which Rafaël promptly accepted (yup, he rocks, but we all know that ;-).
Now, whenever such test fails, you'll get two extra lines:
# searched: "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Trans"...
# can't find: "some random content"
# LCSS: "ome random content"
# LCSS context: "d="content" class="foo">Some random content!</div>"
"LCSS" stands for Longest Common SubString, meaning you get whatever matched the most inside the original content (note that LCSS is not the same as LCS, or Longest Common Subsequence, which would go for a non-sequential match as seen in diff-like outputs). And, of course, "LCSS context" means the surroundings of the LCSS string just found.
Now, just by looking at our example, we know exactly why the test failed, and we are free to fix either the test suite or the application.
Know what's best? You get all that for free, no need to change a single line in your tests. Just update Test::LongString to 0.12 or later and enjoy! :-)
shame the POD's not been updated...
ReplyDeleteIndeed. But Rafael is already aware of this and a new version with the documentation should come out soon. This is one of the reasons for this post =)
ReplyDelete希望能常常看到你的更新 ........................................
ReplyDeleteBUUUUUU!!! te achei!!! =D (quer dizer, te acharam por mim, hahahaha!!!)
ReplyDeleteaparece no meu blog, seu coisa! ó, nem li suas paradas de Perl, ñ entendo bulhufas, literalmente "pérolas aos porcos"!! XD (desculpe o trocadilho infame!!)
Caraca, tem comment aqui até em chinês!! O.o Joga no google translator, hehehe
saudade de vc, viiiu?? Depois eu te falo sobre meu amigo q te achou! ^_^
Beijooooooo!!!
裸體寫真全裸美女圖片色情訊息黃色圖片自拍裸體圖片sex裸露圖片18限85cc a片台灣色情網站免費色情圖一夜激情聊天情色聊天室限制級爆乳女優作愛巨乳學院性愛情慾陰脣一夜情下體網愛聊天鹹濕做愛自拍成人圖庫成人影城性關係視訊情人性影片觀賞裸照淫美成人論壇av寫真自拍裸女貼圖av圖情色性愛貼圖成人vcdsexy辣妹視訊聊天色情視訊淫婦台灣情色論壇丁字褲貼圖免費a片影片淫蕩女人live show男女做愛火辣妹妹激情網愛聊天美女裸照免費色情網站
ReplyDeletehello~~........................................
ReplyDelete