def test_should_format_scalar_array_with_value_comment(self):
        reader = JsonReader('[1,2 /*comment*/,3]')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('- 1\n- 2 # comment\n- 3')
    def test_should_format_nested_object(self):
        reader = JsonReader('{"hello":"world" ,"obj":{"abc":123}}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello: world\nobj:\n  abc: 123')
    def test_should_format_empty_array(self):
        reader = JsonReader('[ ]')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('')
    def test_should_preserve_in_line_comment_block(self):
        reader = JsonReader('{\'"hello"\':"world", /* comment block */ \'value\':123}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('"\\"hello\\"": world # comment block\nvalue: 123')
    def test_should_preserve_new_line_comment_block_in_nested_object(self):
        reader = JsonReader('{obj:{\'hello\':"world",\n/* comment\nblock */ \'value\':123}}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('obj:\n  hello: world\n  # comment\n  # block\n  value: 123')
    def test_should_format_array_of_objects(self):
        reader = JsonReader('{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('arr:\n  -\n    int: 123\n    str: hello\n  -\n    int: 123\n    str: hello')
    def test_should_create_document_with_comments_after_object_property(self):
        reader = JsonReader('{obj:{hello:"world"}/*comment*/}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('obj')
        expect(prop.value.value_type).to_equal('object')

        obj = prop.value.value
        val = prop.value
        expect(obj).not_to_be_null()
        expect(len(obj.children)).to_equal(1)

        prop = obj.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('hello')
        expect(prop.value.value).to_equal('world')
        expect(prop.value.value_type).to_equal('string')

        comm = val.comments[0]
        expect(comm).not_to_be_null()
        expect(comm).to_be_instance_of(Comment)
        expect(comm.value).to_equal('comment')
    def test_should_format_multiple_properties_with_forced_double_quotes(self):
        reader = JsonReader('{hello:"world" ,value:123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world",\n  "value": 123\n}')
    def test_should_format_empty_object(self):
        reader = JsonReader('{ }')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{}')
    def test_should_format_nested_object(self):
        reader = JsonReader('{"hello":"world" ,"obj":{"abc":123}}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world",\n  "obj": {\n    "abc": 123\n  }\n}')
    def test_should_format_object_with_array(self):
        reader = JsonReader('{"hello":"world" ,"arr":["hello","world"]}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world",\n  "arr": ["hello", "world"]\n}')
    def test_should_format_array_of_objects(self):
        reader = JsonReader('{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{\n  "arr": [{\n    "int": 123,\n    "str": "hello"\n  }, {\n    "int": 123,\n    "str": "hello"\n  }]\n}')
    def test_should_format_array_of_objects_with_tabs(self):
        reader = JsonReader('{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'indent_character': '\t'})

        output = renderer.render()
        expect(output).to_equal('{\n\t"arr": [{\n\t\t"int": 123,\n\t\t"str": "hello"\n\t}, {\n\t\t"int": 123,\n\t\t"str": "hello"\n\t}]\n}')
    def test_should_format_array_of_arrays(self):
        reader = JsonReader('[[1,2,3],[4,5,6]]')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('[[1, 2, 3], [4, 5, 6]]')
    def test_should_create_new_collection_with_comment(self):
        reader = JsonReader('[1,2 /*comment*/,-3]')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Collection)
        expect(len(doc.children)).to_equal(3)

        val = doc.children[0]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('1')
        expect(val.value_type).to_equal('number')

        val = doc.children[1]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('2')
        expect(val.value_type).to_equal('number')

        comm = val.comments[0]
        expect(comm).not_to_be_null()
        expect(comm.value).to_equal('comment')

        val = doc.children[2]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('-3')
        expect(val.value_type).to_equal('number')
    def test_should_format_single_property(self):
        reader = JsonReader('{"hello":"world"}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello: world')
    def test_should_create_new_collection_with_comment(self):
        reader = JsonReader('[1,2 /*comment*/,-3]')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Collection)
        expect(len(doc.children)).to_equal(3)

        val = doc.children[0]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('1')
        expect(val.value_type).to_equal('number')

        val = doc.children[1]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('2')
        expect(val.value_type).to_equal('number')

        comm = val.comments[0]
        expect(comm).not_to_be_null()
        expect(comm.value).to_equal('comment')

        val = doc.children[2]
        expect(val).not_to_be_null()
        expect(val.value).to_equal('-3')
        expect(val.value_type).to_equal('number')
    def test_should_preserve_end_line_comment_forcing_new_line_for_subsequent_tokens(self):
        reader = JsonReader('{"hello":"world",\n// full line comment\n\'value\'://comment\n123}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('hello: world\n# full line comment\nvalue: # comment\n  123')
    def test_should_format_property_with_empty_string_and_normalized_strings(self):
        reader = JsonReader('{\'hello\':\'\'}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'force_property_quotes': True, 'normalize_strings': True})

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": ""\n}')
    def test_should_create_document_with_property_value_as_array_of_objects(
            self):
        reader = JsonReader(
            '{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('arr')
        expect(prop.value.value_type).to_equal('array')

        arr = prop.value.value
        expect(arr).not_to_be_null()
        expect(arr).to_be_instance_of(Collection)

        obj = arr.children[0].value
        expect(obj).not_to_be_null()
        expect(obj).to_be_instance_of(Document)

        obj = arr.children[1].value
        expect(obj).not_to_be_null()
        expect(obj).to_be_instance_of(Document)
    def test_should_format_multiple_properties(self):
        reader = JsonReader('{"hello":"world" ,"value":123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world",\n  "value": 123\n}')
    def test_should_preserve_multiple_end_line_comment_forcing_new_line_for_subsequent_tokens(self):
        reader = JsonReader('{\'"hello"\':"world",\n// full line comment\n\'value\'://comment\n//comment\n123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('{\n  "\\"hello\\"": "world",\n  // full line comment\n  "value": //comment\n    //comment\n    123\n}')
    def test_should_format_property_values_with_normalized_strings(self):
        reader = JsonReader('{\'hello\':"world" ,"value":123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'force_property_quotes': True, 'quote_char': '\'', 'normalize_strings': True})

        output = renderer.render()
        expect(output).to_equal('{\n  \'hello\': \'world\',\n  \'value\': 123\n}')
    def test_should_preserve_multiple_line_comments_block(self):
        reader = JsonReader('{\'"hello"\':"world", /* comment block */\n/*comment block*/ \'value\':123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('{\n  "\\"hello\\"": "world", /* comment block */\n  /*comment block*/\n  "value": 123\n}')
    def test_should_format_multiple_properties(self):
        reader = JsonReader('{"hello":"world" ,"value":123}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello: world\nvalue: 123')
    def test_should_format_empty_object(self):
        reader = JsonReader('{ }')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{}')
    def test_should_create_document_with_comments_after_object_property(self):
        reader = JsonReader('{obj:{hello:"world"}/*comment*/}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('obj')
        expect(prop.value.value_type).to_equal('object')

        obj = prop.value.value
        val = prop.value
        expect(obj).not_to_be_null()
        expect(len(obj.children)).to_equal(1)

        prop = obj.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('hello')
        expect(prop.value.value).to_equal('world')
        expect(prop.value.value_type).to_equal('string')

        comm = val.comments[0]
        expect(comm).not_to_be_null()
        expect(comm).to_be_instance_of(Comment)
        expect(comm.value).to_equal('comment')
    def test_should_format_scalar_array(self):
        reader = JsonReader('[1,2,3]')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('[1, 2, 3]')
    def test_should_format_array_of_arrays(self):
        reader = JsonReader('[[1,2,3],[4,5,6]]')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('[[1, 2, 3], [4, 5, 6]]')
    def test_should_format_single_property(self):
        reader = JsonReader('{"hello":"world"}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world"\n}')
    def test_should_format_property_with_empty_string(self):
        reader = JsonReader('{\'hello\':\'\'}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello:')
    def test_should_create_document_new_line_comment_block(self):
        reader = JsonReader(
            '{\'"hello"\':"world",\n/* comment\nblock */ \'value\':123}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(3)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('"hello"')
        expect(prop.value.value).to_equal('world')
        expect(prop.value.value_type).to_equal('string')

        comm = doc.children[1]
        expect(comm).not_to_be_null()
        expect(comm).to_be_instance_of(Comment)
        expect(comm.value).to_equal('comment\nblock')

        prop = doc.children[2]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('value')
        expect(prop.value.value).to_equal('123')
        expect(prop.value.value_type).to_equal('number')
    def test_should_format_property_with_empty_string(self):
        reader = JsonReader('{\'hello\':\'\'}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello:')
    def test_should_format_scalar_array_with_value_comment(self):
        reader = JsonReader('[1,2 /*comment*/,3]')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('- 1\n- 2 # comment\n- 3')
    def test_should_format_scalar_array(self):
        reader = JsonReader('[1,2,3]')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('- 1\n- 2\n- 3')
    def test_should_format_empty_array(self):
        reader = JsonReader('[ ]')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('')
    def test_should_format_nested_object(self):
        reader = JsonReader('{"hello":"world" ,"obj":{"abc":123}}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello: world\nobj:\n  abc: 123')
    def test_should_format_object_with_array(self):
        reader = JsonReader('{"hello":"world" ,"arr":["hello","world"]}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal('hello: world\narr:\n  - hello\n  - world')
    def test_should_format_nested_object(self):
        reader = JsonReader('{"hello":"world" ,"obj":{"abc":123}}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal(
            '{\n  "hello": "world",\n  "obj": {\n    "abc": 123\n  }\n}')
    def test_should_format_multiple_properties_with_forced_double_quotes(self):
        reader = JsonReader('{hello:"world" ,value:123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": "world",\n  "value": 123\n}')
    def test_should_preserve_end_line_comment(self):
        reader = JsonReader('{\'"hello"\':"world", // comment\n\'value\':123}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('"\\"hello\\"": world # comment\nvalue: 123')
Exemple #42
0
    def format(self, text, options):
        reader = JsonReader(text)
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document, {'indent_character': options['indent_character']})
        formattedText = renderer.render()

        self.view.set_syntax_file('Packages/YAML/YAML.tmLanguage')

        return formattedText
    def test_should_preserve_new_line_comment_block(self):
        reader = JsonReader(
            '{"hello":"world",\n/* comment\nblock */ \'value\':123}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal('hello: world\n# comment\n# block\nvalue: 123')
    def test_should_format_array_of_objects_with_tabs(self):
        reader = JsonReader(
            '{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document, {'indent_character': '\t'})

        output = renderer.render()
        expect(output).to_equal(
            'arr:\n\t-\n\t\tint: 123\n\t\tstr: hello\n\t-\n\t\tint: 123\n\t\tstr: hello'
        )
    def test_should_format_array_of_objects(self):
        reader = JsonReader(
            '{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal(
            '{\n  "arr": [{\n    "int": 123,\n    "str": "hello"\n  }, {\n    "int": 123,\n    "str": "hello"\n  }]\n}'
        )
    def test_should_format_array_of_objects(self):
        reader = JsonReader(
            '{"arr":[{"int":123,"str":"hello"},{"int":123,"str":"hello"}]}')
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document)

        output = renderer.render()
        expect(output).to_equal(
            'arr:\n  -\n    int: 123\n    str: hello\n  -\n    int: 123\n    str: hello'
        )
    def test_should_format_properties_with_forced_single_quotes(self):
        reader = JsonReader('{\'hello\':"world" ,"value":123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {
            'force_property_quotes': True,
            'quote_char': '\''
        })

        output = renderer.render()
        expect(output).to_equal(
            '{\n  \'hello\': \'world\',\n  \'value\': 123\n}')
    def test_should_format_property_with_empty_string_and_normalized_strings(
            self):
        reader = JsonReader('{\'hello\':\'\'}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document, {
            'force_property_quotes': True,
            'normalize_strings': True
        })

        output = renderer.render()
        expect(output).to_equal('{\n  "hello": ""\n}')
    def test_should_preserve_in_line_comment_block(self):
        reader = JsonReader(
            '{\'"hello"\':"world", /* comment block */ \'value\':123}')
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal(
            '{\n  "\\"hello\\"": "world", /* comment block */\n  "value": 123\n}'
        )
    def test_should_preserve_end_line_comment_forcing_new_line_for_subsequent_tokens(
            self):
        reader = JsonReader(
            '{"hello":"world",\n// full line comment\n\'value\'://comment\n123}'
        )
        document = document_builder.build(reader)
        renderer = YamlDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal(
            'hello: world\n# full line comment\nvalue: # comment\n  123')
    def test_should_preserve_multiple_end_line_comment_forcing_new_line_for_subsequent_tokens(
            self):
        reader = JsonReader(
            '{\'"hello"\':"world",\n// full line comment\n\'value\'://comment\n//comment\n123}'
        )
        document = document_builder.build(reader)
        renderer = JsonDocumentRenderer(document,
                                        {'force_property_quotes': True})

        output = renderer.render()
        expect(output).to_equal(
            '{\n  "\\"hello\\"": "world",\n  // full line comment\n  "value": //comment\n    //comment\n    123\n}'
        )
    def test_should_create_document_with_property(self):
        reader = JsonReader('{ab: 123}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('ab')
        expect(prop.value.value).to_equal('123')
        expect(prop.value.value_type).to_equal('number')
    def test_should_create_document_with_string_property(self):
        reader = JsonReader('{"a": "4"}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('a')
        expect(prop.value.value).to_equal('4')
        expect(prop.value.value_type).to_equal('string')
    def test_should_create_document_with_property(self):
        reader = JsonReader('{ab: 123}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('ab')
        expect(prop.value.value).to_equal('123')
        expect(prop.value.value_type).to_equal('number')
    def test_should_create_document_with_string_property(self):
        reader = JsonReader('{"a": "4"}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('a')
        expect(prop.value.value).to_equal('4')
        expect(prop.value.value_type).to_equal('string')
    def test_should_create_new_collection_of_collections(self):
        reader = JsonReader('[[1],[2]]')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Collection)
        expect(len(doc.children)).to_equal(2)

        val = doc.children[0]
        expect(val).not_to_be_null()
        #expect(val.value).to_equal('1')
        expect(val.value_type).to_equal('array')

        val = doc.children[1]
        expect(val).not_to_be_null()
        #expect(val.value).to_equal('2.')
        expect(val.value_type).to_equal('array')
    def test_should_create_new_collection_of_collections(self):
        reader = JsonReader('[[1],[2]]')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Collection)
        expect(len(doc.children)).to_equal(2)

        val = doc.children[0]
        expect(val).not_to_be_null()
        #expect(val.value).to_equal('1')
        expect(val.value_type).to_equal('array')

        val = doc.children[1]
        expect(val).not_to_be_null()
        #expect(val.value).to_equal('2.')
        expect(val.value_type).to_equal('array')
    def test_should_create_document_with_property_value_block_comment(self):
        reader = JsonReader('{a: true /* block\ncomment */}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('a')
        expect(prop.value.value).to_equal('true')
        expect(prop.value.value_type).to_equal('boolean')

        comm = prop.value.comments[0]
        expect(comm).not_to_be_null()
        expect(comm.comment_type).to_equal('block')
        expect(comm.value).to_equal('block\ncomment')
    def test_should_create_document_with_property_value_line_comment(self):
        reader = JsonReader('{a:// line comment\n-74.0}')
        doc = document_builder.build(reader)

        expect(doc).not_to_be_null()
        expect(doc).to_be_instance_of(Document)
        expect(len(doc.children)).to_equal(1)

        prop = doc.children[0]
        expect(prop).not_to_be_null()
        expect(prop.name.value).to_equal('a')
        expect(prop.value.value).to_equal('-74.0')
        expect(prop.value.value_type).to_equal('number')

        comm = prop.name.comments[0]
        expect(comm).not_to_be_null()
        expect(comm.comment_type).to_equal('end_line_comment')
        expect(comm.value).to_equal('line comment')