File: yang_spec.rb

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (84 lines) | stat: -rw-r--r-- 2,346 bytes parent folder | download | duplicates (4)
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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

describe Rouge::Lexers::YANG do
  let(:subject) { Rouge::Lexers::YANG.new }

  describe 'guessing' do
    include Support::Guessing

    it 'guesses by filename' do
      assert_guess :filename => 'test.yang'
    end

    it 'guesses by mimetype' do
      assert_guess :mimetype => 'application/yang'
    end

    describe 'lexing' do
      include Support::Lexing

      it 'parse namespace uri' do
        assert_tokens_equal 'namespace urn:ietf:params:xml:ns:yang:ietf-alarms;',
          ['Keyword.Declaration', 'namespace'],
          ['Text.Whitespace', ' '],
          ['Name', 'urn:ietf:params:xml:ns:yang:ietf-alarms'],
          ['Punctuation', ';']
      end

      it 'parse namespace prefix' do
        assert_tokens_equal 'type yang:counter64;',
          ['Keyword.Declaration', 'type'],
          ['Text.Whitespace', ' '],
          ['Name.Namespace', 'yang'],
          ['Punctuation', ":"],
          ['Name', 'counter64'],
          ['Punctuation', ';']
      end

      it 'parse revision-date' do
        assert_tokens_equal 'revision 2020-03-08{',
          ['Keyword.Declaration', 'revision'],
          ['Text.Whitespace', ' '],
          ['Name.Label', '2020-03-08'],
          ['Punctuation', '{']
      end

      it 'parse float in yang-version' do
        assert_tokens_equal 'yang-version 1.1;',
          ['Keyword.Declaration', 'yang-version'],
          ['Text.Whitespace', ' '],
          ['Literal.Number.Float', '1.1'],
          ['Punctuation', ';']
      end

      it 'parse integer in value' do
        assert_tokens_equal 'value 5;',
          ['Keyword.Declaration', 'value'],
          ['Text.Whitespace', ' '],
          ['Literal.Number.Integer', '5'],
          ['Punctuation', ';']
      end

      it 'parse integer in value' do
        assert_tokens_equal 'value "5";',
          ['Keyword.Declaration', 'value'],
          ['Text.Whitespace', ' '],
          ['Literal.String.Double', '"5"'],
          ['Punctuation', ';']
      end

      it 'parse complex name' do
        assert_tokens_equal ' +abc*iu{ asd;}',
          ['Text.Whitespace', ' '],
          ['Name', '+abc*iu'],
          ['Punctuation', '{'],
          ['Text.Whitespace', ' '],
          ['Name', 'asd'],
          ['Punctuation', ';}']
      end

    end

  end
end