Class: TestLangHelp
- Includes:
- LangHelp
- Defined in:
- lib/el4r/emacsruby/test-langhelp.rb
Instance Method Summary collapse
- #_test_langhelp_narrow_to_section(line, result, contents) ⇒ Object
- #assert_search(str) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_C_u ⇒ Object
- #test_default ⇒ Object
- #test_el4r ⇒ Object
- #test_index_buffer ⇒ Object
- #test_info ⇒ Object
- #test_langhelp_narrow_to_section ⇒ Object
- #test_lh_to ⇒ Object
- #test_lh_xxx ⇒ Object
-
#test_newer ⇒ Object
def test_concat Dir.chdir(@langhelp_home) do begin hoge = “content of hoge.en” echo = “content of echo.en” hoge.writef “hoge.e” echo.writef “echo.e” newbuf(:name=>“xxxx”, :contents=>“”, :display=>:pop) { concat_mode} langhelp assert_equal(hoge + echo, buffer_string) ensure FileUtils.rm_f %w[hoge.e echo.e] end end end.
- #test_occur ⇒ Object
- #test_revert_buffer ⇒ Object
- #test_ruby ⇒ Object
- #test_test_test0 ⇒ Object
-
#test_w3m_label ⇒ Object
(lh-w3m nil “file:///home/rubikitch/src/langhelp/langhelp.en.html#Title:”) (lh-w3m nil “file:///home/rubikitch/src/langhelp/langhelp.en.html#1”).
- #xtest_face ⇒ Object
Instance Method Details
#_test_langhelp_narrow_to_section(line, result, contents) ⇒ Object
261 262 263 264 265 266 267 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 261 def _test_langhelp_narrow_to_section(line, result, contents) newbuf(:name=>"xxxx", :contents=>contents) do goto_line line langhelp_narrow_to_section assert_equal result, buffer_string end end |
#assert_search(str) ⇒ Object
100 101 102 103 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 100 def assert_search(str) goto_char 1 assert( search_forward(str, nil, true) ) end |
#setup ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 24 def setup @header = "/tmp/langhelpheader" open(@header, "w"){} @langhelp_home = File.("../../../test", File.dirname(File.(__FILE__))) @langhelprc = Tempfile.path(<<-EOR) # -*- ruby -*- @LANGHELP_HOME = #{@langhelp_home.dump} @HTML2TXT = "w3m -dump -T text/html" @lang = {} @aliases = {} @lang["ruby"] = [ {:Ri => true}, ] @aliases["ruby"] = %w[el4r] @lang["hoge"] = {:HogeHelp => true, :cmd=>"echo"} @lang["echo"] = {:Echo => true} @lang["test-test0"] = {:Test0 => true} @lang["concat"] = [ "hoge", "echo" ] @occur_by_grep = true EOR # *.e must exist! el4r.instance_eval do def ruby_mode(*x) elvar.major_mode = :ruby_mode end def el4r_mode(*x) elvar.major_mode = :el4r_mode end def test_test0_mode(*x) elvar.major_mode = :test_test0_mode end def concat_mode(*x) elvar.major_mode = :concat_mode end def isearch_forward(*x) end def winconf_push(*x) end end # *langhelp:x* buffer is empty in this test # So ee-anchor-format must be set! elvar.ee_anchor_format = "<<<%s>>>" @x = LangHelp.run(:langhelprc=>@langhelprc) end |
#teardown ⇒ Object
65 66 67 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 65 def teardown File.unlink(@header) end |
#test_C_u ⇒ Object
203 204 205 206 207 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 203 def test_C_u newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { ruby_mode } langhelp 4 assert_equal "*langhelp index*", buffer_name end |
#test_default ⇒ Object
196 197 198 199 200 201 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 196 def test_default assert get_buffer("*langhelp index*") newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { fundamental_mode } langhelp assert_equal "*langhelp index*", buffer_name end |
#test_el4r ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 117 def test_el4r # alias test assert_instance_of(LangHelp, @x) newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { el4r_mode} langhelp assert_equal("*langhelp:ruby*", buffer_name) assert_search "lh-ri" assert( fboundp(:lh_ri) ) assert( fboundp(:lh_hogehelp) ) end |
#test_index_buffer ⇒ Object
167 168 169 170 171 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 167 def test_index_buffer langhelp_switch_to_index_buffer assert_equal("*langhelp index*", buffer_name) assert_search "lh-language-index" end |
#test_info ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 209 def test_info lh_info "Distribution", "(emacs)Distrib" with(:with_current_buffer, "*info*<langhelp>") do assert_equal "Distrib", elvar.Info_current_node assert_match /emacs$/, elvar.Info_current_file end end |
#test_langhelp_narrow_to_section ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 269 def test_langhelp_narrow_to_section contents = <<XXX <<< zero >>> <<< one >>> ONE <<< two >>> TWO XXX zero = <<XXX <<< zero >>> XXX one = <<XXX <<< one >>> ONE XXX two = <<XXX <<< two >>> TWO XXX _test_langhelp_narrow_to_section 1, zero, contents _test_langhelp_narrow_to_section 2, one, contents _test_langhelp_narrow_to_section 3, one, contents _test_langhelp_narrow_to_section 4, two, contents _test_langhelp_narrow_to_section 5, two, contents end |
#test_lh_to ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 243 def test_lh_to contents = <<XXX == Foo == foo == Bar == bar XXX newbuf(:name=>"xxxx", :contents=>contents) do make_local_variable :ee_anchor_format elvar.ee_anchor_format = "== %s ==" lh_to "Bar" beginning_of_line assert looking_at("^== Bar ==") end end |
#test_lh_xxx ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 145 def test_lh_xxx set_buffer lh_hogehelp("x") assert_equal(`echo x`, buffer_string) # default CMD == class.to_s.downcase assert( fboundp :lh_echo ) set_buffer lh_echo("y") assert_equal(`echo y`, buffer_string) set_buffer lh_test0("z") assert_equal("0\n", buffer_string) end |
#test_newer ⇒ Object
def test_concat
Dir.chdir(@langhelp_home) do
begin
hoge = "content of hoge.e\n"
echo = "content of echo.e\n"
hoge.writef "hoge.e"
echo.writef "echo.e"
newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { concat_mode}
langhelp
assert_equal(hoge + echo, buffer_string)
ensure
FileUtils.rm_f %w[hoge.e echo.e]
end
end
end
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 86 def test_newer @x = LangHelpInternal.new(:major_mode=>"ruby", :datadir=>@langhelp_home) @x.create_buffer now = Time.now # Header is older. File.utime(now, now-100, @header) assert_equal(false, @x.header_is_newer_than_buffer(@header)) # Header is newer. File.utime(now, now+100, @header) assert_equal(true, @x.header_is_newer_than_buffer(@header)) end |
#test_occur ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 159 def test_occur newbuf(:name=>"*langhelp:hoge*", :contents=>"abc\ndef\nabc\n", :display=>:only) langhelp_occur "abc" assert_equal "*langhelp occur /abc/*", buffer_name assert_equal "abc\nabc\n", buffer_string end |
#test_revert_buffer ⇒ Object
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 173 def test_revert_buffer newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { ruby_mode} langhelp assert_equal("*langhelp:ruby*", buffer_name) assert_search "lh-ri" let(:buffer_read_only, nil){ erase_buffer } assert_equal 0, buffer_size langhelp_revert_buffer assert_search "lh-ri" end |
#test_ruby ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 105 def test_ruby assert_instance_of(LangHelp, @x) newbuf(:name=>"xxxx", :contents=>"", :display=>:pop) { ruby_mode} langhelp assert_equal("*langhelp:ruby*", buffer_name) assert_search "lh-ri" assert( fboundp(:lh_ri) ) assert( fboundp(:lh_hogehelp) ) end |
#test_test_test0 ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 131 def test_test_test0 begin e_file = File.join(@langhelp_home, "test-test0.e") open(e_file,"w"){} newbuf(:name=>"test0", :contents=>"", :display=>:pop) { test_test0_mode} langhelp assert_equal("*langhelp:test-test0*", buffer_name) ensure FileUtils.rm_f e_file end end |
#test_w3m_label ⇒ Object
(lh-w3m nil “file:///home/rubikitch/src/langhelp/langhelp.en.html#Title:”) (lh-w3m nil “file:///home/rubikitch/src/langhelp/langhelp.en.html#1”)
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 219 def test_w3m_label begin html = File. "../../../langhelp.en.html", Dir.scriptdir url = "file://#{html}#Title:" lh_w3m nil, url with(:with_current_buffer, "*w3m*") do assert_match /Title:/, thing_at_point(:line) end # reuse the *w3m* buffer when URL is same url = "file://#{html}#1" lh_w3m nil, url with(:with_current_buffer, "*w3m*") do assert_match /1 /, thing_at_point(:line) end assert_equal 1, length(w3m_list_buffers) ensure kill_buffer "*w3m*" end end |
#xtest_face ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/el4r/emacsruby/test-langhelp.rb', line 184 def xtest_face # Because font-lock-mode is off at batch mode, this test fails. # (view-efile "font-lock.el" " (when (or noninteractive") let(:noninteractive, nil) do newbuf(:name=>"yyyy", :contents=>"# (lh-foo \"\")\n", :display=>:only, :point=>6) font_lock_mode 1 assert_equal :langhelp_sexp_face, get_char_property(5, :face) end end |