require 'test/unit'
require 'coderay'
class HtmlTest < Test::Unit::TestCase
def test_break_lines_option
snippets = {}
snippets[:ruby] = {}
snippets[:ruby][:in] = <<-RUBY
ruby_inside = <<-RUBY_INSIDE
This is tricky,
isn't it?
RUBY_INSIDE
RUBY
snippets[:ruby][:expected_with_option_off] = <<-HTML_OPT_INDEPENDENT_LINES_OFF
ruby_inside = <<-RUBY_INSIDE
This is tricky,
isn't it?
RUBY_INSIDE
HTML_OPT_INDEPENDENT_LINES_OFF
snippets[:ruby][:expected_with_option_on] = <<-HTML_OPT_INDEPENDENT_LINES_ON
ruby_inside = <<-RUBY_INSIDE
This is tricky,
isn't it?
RUBY_INSIDE
HTML_OPT_INDEPENDENT_LINES_ON
snippets[:java] = {}
snippets[:java][:in] = <<-JAVA
import java.lang.*;
/**
* This is some multiline javadoc
* used to test the
*/
public class Test {
public static final String MESSAGE = "My message\
To the world";
static void main() {
/*
* Another multiline
* comment
*/
System.out.println(MESSAGE);
}
}
JAVA
snippets[:java][:expected_with_option_off] = <<-HTML_OPT_INDEPENDENT_LINES_OFF
import java.lang.*;
public class Test {
public static final String MESSAGE = "My message To the world";
static void main() {
System.out.println(MESSAGE);
}
}
HTML_OPT_INDEPENDENT_LINES_OFF
snippets[:java][:expected_with_option_on] = <<-HTML_OPT_INDEPENDENT_LINES_ON
import java.lang.*;
public class Test {
public static final String MESSAGE = "My message To the world";
static void main() {
System.out.println(MESSAGE);
}
}
HTML_OPT_INDEPENDENT_LINES_ON
for lang, code in snippets
tokens = CodeRay.scan code[:in], lang
assert_equal code[:expected_with_option_off], tokens.html
assert_equal code[:expected_with_option_off], tokens.html(:break_lines => false)
assert_equal code[:expected_with_option_on], tokens.html(:break_lines => true)
end
end
end