File: duo.rb

package info (click to toggle)
coderay 1.1.3-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,368 kB
  • sloc: ruby: 9,987; makefile: 14; sh: 4; python: 1
file content (35 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'test/unit'
require 'yaml'
require 'coderay'

class DuoTest < Test::Unit::TestCase
  
  def test_two_arguments
    duo = CodeRay::Duo[:ruby, :html]
    assert_kind_of CodeRay::Scanners[:ruby], duo.scanner
    assert_kind_of CodeRay::Encoders[:html], duo.encoder
  end
  
  def test_two_hash
    duo = CodeRay::Duo[:ruby => :html]
    assert_kind_of CodeRay::Scanners[:ruby], duo.scanner
    assert_kind_of CodeRay::Encoders[:html], duo.encoder
  end
  
  def test_call
    duo = CodeRay::Duo[:python => :yml]
    yaml = [["def", :keyword],
            [" ", :space],
            ["test", :method],
            [":", :operator],
            [" ", :space],
            [:begin_group, :string],
            ["\"", :delimiter],
            ["pass", :content],
            ["\"", :delimiter],
            [:end_group, :string]]
    
    assert_equal yaml, YAML.load(duo.call('def test: "pass"'))
  end
  
end