require("lunit") discount = require("discount") module("test discount", lunit.testcase, package.seeall) function test_basic_conversion() assert_equal("
Hello World.
\n", discount("Hello World.")) end function test_relaxed_emphasis() assert_equal("Hello World!
\n", discount("_Hello World_!")) assert_equal("under_score this_stuff
\n", discount("under_score this_stuff")) local input = "_start _ foo_bar bar_baz _ end_ *italic* **bold** _blah_" local expected_out = "start _ foo_bar bar_baz _ end italic bold blah
\n" assert_equal(expected_out, discount(input)) end function test_nolinks() assert_equal("[example](http://example.com)
\n", discount("[example](http://example.com)", "nolinks")) assert_equal('<a href="http://example.com">example
\n', discount('example', "nolinks")) end function test_noimages() assert_equal("![example](example.png)
\n", discount("![example](example.png)", "noimages")) assert_equal('<img src="example.png"/>
\n', discount('', "noimages")) end function test_nopants() assert_equal('“quote”
\n', discount('"quote"')) assert_equal('"quote"
\n', discount('"quote"', "nopants")) end function test_nohtml() local expected = "This should <em>not</em> be allowed
\n" assert_equal(expected, discount("This should not be allowed", "nohtml")) end function test_cdata() assert_equal("<p>foo</p>\n", discount("foo", "cdata")) end