def test_symbol_ref_not_equals_symbol_ref_with_different_symbol_name(self):
     # ARRANGE #
     expected = list_sdvs.symbol_element(reference_to__on_direct_and_indirect('expected_symbol_name'))
     actual = list_sdvs.symbol_element(reference_to__on_direct_and_indirect('actual_symbol_name'))
     assertion = sut.equals_list_sdv_element(expected)
     # ACT & ASSERT #
     assert_that_assertion_fails(assertion, actual)
 def test_symbol_ref_not_equals_string(self):
     # ARRANGE #
     string_element = list_sdvs.str_element('value')
     symbol_reference_element = list_sdvs.symbol_element(reference_to__on_direct_and_indirect('symbol_name'))
     assertion = sut.equals_list_sdv_element(symbol_reference_element)
     # ACT & ASSERT #
     assert_that_assertion_fails(assertion, string_element)
 def test_symbol_that_does_not_meet_restriction_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_name = 'symbol_name'
     reference_to_string_symbol = data_references.reference_to__on_direct_and_indirect(
         symbol_name, value_restrictions.is_string())
     definition_of_path_symbol = arbitrary_path_symbol_context(
         symbol_name).definition
     symbol_usages = [
         definition_of_path_symbol,
         reference_to_string_symbol,
     ]
     self._check(
         Arrangement(test_case, atc_symbol_usages=do_return(symbol_usages)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.VALIDATION_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_step(
                     phase_step.ACT__VALIDATE_SYMBOLS),
             ),
             [
                 phase_step.ACT__PARSE,
                 phase_step.SETUP__VALIDATE_SYMBOLS,
                 phase_step.ACT__VALIDATE_SYMBOLS,
             ],
         ))
 def test_equals(self):
     cases = [
         list_sdvs.from_str_constants(['value']),
         list_sdvs.from_elements([list_sdvs.symbol_element(reference_to__on_direct_and_indirect('symbol_name'))]),
     ]
     for sdv in cases:
         with self.subTest(msg=str(sdv)):
             sut.equals_list_sdv(sdv).apply_without_message(self, sdv)
 def test_equals(self):
     test_cases = [
         list_sdvs.str_element('value'),
         list_sdvs.symbol_element(reference_to__on_direct_and_indirect('symbol_name')),
     ]
     for element in test_cases:
         with self.subTest(msg=str(element)):
             sut.equals_list_sdv_element(element).apply_without_message(self, element)
 def test_expect_no_symbol_usages(self):
     self._check_raises_test_error__single_and_multi(
         _constant_line_matcher_type_parser_of_matcher_sdv(
             sdv_ddv.sdv_from_primitive_value(
                 references=[
                     data_references.reference_to__on_direct_and_indirect('symbol_name')])
         ),
         is_expectation_of_execution_result_of(True),
     )
Exemple #7
0
 def test_that_default_expectation_assumes_no_symbol_usages(self):
     unexpected_symbol_usages = [
         data_references.reference_to__on_direct_and_indirect('symbol_name')]
     self._check_source_and_exe_variants__failing_assertions(
         ParserThatGives(
             instruction_embryo_that__phase_agnostic(
                 symbol_usages=do_return(unexpected_symbol_usages))),
         Arrangement.phase_agnostic(),
         Expectation.phase_agnostic(),
     )
 def test_not_equals__list(self):
     # ARRANGE #
     expected = list_sdvs.from_str_constants(['value'])
     actual = list_sdvs.from_elements([
         list_sdvs.symbol_element(
             data_references.reference_to__on_direct_and_indirect(
                 'symbol_name'))
     ])
     # ACT & ASSERT #
     assert_that_assertion_fails(sut.equals_data_type_sdv(expected), actual)
Exemple #9
0
    def test_SHOULD_match_WHEN_references_match(self):
        # ARRANGE #
        actual_reference = data_references.reference_to__on_direct_and_indirect(
            'referenced element')
        actual_references = [actual_reference]
        actual_sdv = arbitrary_sdv_with_references(actual_references)

        assertion_to_check = _matches_string_matcher_sdv(
            references=asrt.matches_sequence([asrt.is_(actual_reference)]), )
        # ACT & ASSERT #
        assertion_to_check.apply_without_message(self, actual_sdv)
Exemple #10
0
 def test_fragments(self):
     # ARRANGE #
     fragment_1 = impl.ConstantStringFragmentSdv('fragment 1 value')
     fragment_2 = impl.SymbolStringFragmentSdv(
         data_references.reference_to__on_direct_and_indirect(
             'symbol_name'))
     sdv = sut.StringSdv((fragment_1, fragment_2))
     # ACT #
     actual = sdv.fragments
     # ASSERT #
     assertion = equals_string_fragments([fragment_1, fragment_2])
     assertion.apply_without_message(self, actual)
Exemple #11
0
 def test_elements(self):
     # ARRANGE #
     element_1 = list_sdvs.str_element('constant value')
     element_2 = list_sdvs.symbol_element(
         data_references.reference_to__on_direct_and_indirect('symbol_name'))
     sdv = sut.ListSdv([element_1, element_2])
     # ACT #
     actual = sdv.elements
     # ASSERT #
     assertion = asrt.matches_sequence([equals_list_sdv_element(element_1),
                                        equals_list_sdv_element(element_2)])
     assertion.apply_without_message(self, actual)
Exemple #12
0
 def test_that_default_expectation_assumes_no_symbol_usages(self):
     with self.assertRaises(utils.TestError):
         unexpected_symbol_usages = [
             data_references.reference_to__on_direct_and_indirect('symbol_name')]
         self._check(
             utils.ParserThatGives(
                 before_assert_phase_instruction_that(
                     symbol_usages=do_return(unexpected_symbol_usages))),
             single_line_source(),
             sut.arrangement(),
             sut.Expectation(),
         )
Exemple #13
0
    def test_fail_due_to_unexpected_references(self):
        # ARRANGE #
        reference = data_references.reference_to__on_direct_and_indirect(
            'symbol_name')
        string_sdv_with_single_reference = _StringSdvTestImpl(
            explicit_references=[reference])

        assertion = sut.matches_sdv(asrt.anything_goes(),
                                    asrt.is_empty_sequence,
                                    asrt.anything_goes())
        # ACT & ASSERT #
        test_of_test_resources_util.assert_that_assertion_fails(
            assertion, string_sdv_with_single_reference)
Exemple #14
0
 def test_success(self):
     # ARRANGE #
     path_symbol = PathDdvSymbolContext(
         'symbol_name', path_ddvs.of_rel_option(RelOptionType.REL_ACT))
     reference = data_references.reference_to__on_direct_and_indirect(
         path_symbol.name)
     path_sdv = PathSdvTestImplWithConstantPathAndSymbolReferences(
         path_symbol.ddv, [reference])
     assertion = sut.matches_sdv(asrt.is_instance(PathSdv),
                                 asrt.len_equals(1),
                                 asrt.is_(path_symbol.ddv),
                                 asrt.is_(path_sdv),
                                 symbols=path_symbol.symbol_table)
     # ACT & ASSERT #
     assertion.apply_without_message(self, path_sdv)
    def test_that_fails_due_to_missing_symbol_reference(self):
        symbol_usages_of_matcher = []
        symbol_usages_of_expectation = [
            data_references.reference_to__on_direct_and_indirect('symbol_name')]

        self._check_raises_test_error__single_and_multi(
            _constant_line_matcher_type_parser_of_matcher_sdv(
                sdv_ddv.sdv_from_primitive_value(references=symbol_usages_of_matcher)
            ),
            Expectation(
                ParseExpectation(
                    symbol_references=sym_asrt.equals_symbol_references__w_str_rendering(
                        symbol_usages_of_expectation)
                ),
            )
        )
Exemple #16
0
    def test_resolve_of_list_symbol_SHOULD_give_list_value(self):
        # ARRANGE #
        string_value_1 = 'string value 1'
        string_value_2 = 'string value 2'
        list_symbol = ListConstantSymbolContext(
            'the_symbol_name', [string_value_1, string_value_2])
        symbol_reference = data_references.reference_to__on_direct_and_indirect(
            list_symbol.name)
        fragment = impl.SymbolStringFragmentSdv(symbol_reference)

        symbol_table = list_symbol.symbol_table
        # ACT #
        actual = fragment.resolve(symbol_table)
        # ASSERT #
        self.assertIsInstance(actual, csv.ListFragmentDdv)
        assertion = equals_string_fragment_ddv(
            csv.ListFragmentDdv(list_symbol.ddv))
        assertion.apply_without_message(self, actual)
Exemple #17
0
    def test_string_token(self):
        # ARRANGE #
        plain_string = 'plain'
        symbol_name = 'symbol_name'

        string_symbol = StringSymbolContext.of_arbitrary_value(symbol_name)
        cases = [
            Case.of(
                'plain string',
                ArgumentOfRichStringAbsStx.of_str(plain_string),
                ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[list_sdvs.str_element(plain_string)],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of(
                'continuation token followed by plain string on next line',
                ContinuationTokenFollowedByArgumentAbsStx(
                    ArgumentOfRichStringAbsStx.of_str(plain_string)),
                ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[list_sdvs.str_element(plain_string)],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of(
                'symbol reference',
                ArgumentOfSymbolReferenceAbsStx(symbol_name),
                Arrangement(string_symbol.symbol_table),
                Expectation(
                    elements=[
                        list_sdvs.symbol_element(
                            reference_to__on_direct_and_indirect(symbol_name))
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.matches_sequence(
                        [string_symbol.reference_assertion__w_str_rendering]),
                )),
        ]
        # ACT & ASSERT #
        _test_cases_w_source_variants(self, cases)
Exemple #18
0
    def test_SHOULD_not_match_WHEN_references_do_not_match(self):
        # ARRANGE #
        actual_reference = data_references.reference_to__on_direct_and_indirect(
            'referenced element')
        actual_references = [actual_reference]
        actual_sdv = arbitrary_sdv_with_references(actual_references)

        cases = [
            NameAndValue('assert no references', asrt.is_empty_sequence),
            NameAndValue(
                'assert single invalid reference',
                asrt.matches_sequence([asrt.not_(asrt.is_(actual_reference))
                                       ])),
        ]

        for case in cases:
            with self.subTest(name=case.name):
                assertion_to_check = _matches_string_matcher_sdv(
                    references=case.value)
                # ACT & ASSERT #
                assert_that_assertion_fails(assertion_to_check, actual_sdv)
 def test_symbol_that_does_meet_restriction_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_name = 'symbol_name'
     reference_to_string_symbol = data_references.reference_to__on_direct_and_indirect(
         symbol_name, value_restrictions.is_string())
     definition_of_string_symbol = StringConstantSymbolContext(
         symbol_name).definition
     symbol_usages = [
         definition_of_string_symbol,
         reference_to_string_symbol,
     ]
     self._check(
         Arrangement(
             test_case,
             atc_symbol_usages=do_return(symbol_usages),
             atc_execute=execute_action_that_returns_exit_code(128)),
         Expectation(
             asrt_result.matches2(
                 None,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(
                     128),
                 ExpectedFailureForNoFailure(),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
             PRE_SDS_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.ASSERT__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
             ],
         ))
 def test_reference_to_undefined_symbol_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_usages_with_ref_to_undefined_symbol = [
         data_references.reference_to__on_direct_and_indirect(
             'undefined_symbol')
     ]
     self._check(
         Arrangement(test_case,
                     atc_symbol_usages=do_return(
                         symbol_usages_with_ref_to_undefined_symbol)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.VALIDATION_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_step(
                     phase_step.ACT__VALIDATE_SYMBOLS),
             ),
             [
                 phase_step.ACT__PARSE,
                 phase_step.SETUP__VALIDATE_SYMBOLS,
                 phase_step.ACT__VALIDATE_SYMBOLS,
             ],
         ))
Exemple #21
0
    def test(self):
        # ARRANGE #
        plain_string1 = 'plain_1'
        plain_string2 = 'plain_2'
        symbol_name_1 = 'symbol_name_1'
        symbol_name_2 = 'symbol_name_2'
        remaining_part_of_current_line_with_sym_ref = ''.join([
            'before',
            symbol_reference_syntax_for_name(symbol_name_2), 'after'
        ])

        cases = [
            Case.of_multi(
                'plain strings', [
                    ArgumentOfRichStringAbsStx.of_str(plain_string1),
                    ArgumentOfRichStringAbsStx.of_str(plain_string2)
                ], ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[
                        list_sdvs.str_element(plain_string1),
                        list_sdvs.str_element(plain_string2)
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of_multi(
                'plain strings on several lines (separated by continuation token)',
                [
                    ArgumentOfRichStringAbsStx.of_str(plain_string1),
                    ContinuationTokenFollowedByArgumentAbsStx(
                        ArgumentOfRichStringAbsStx.of_str(plain_string2)),
                ], ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[
                        list_sdvs.str_element(plain_string1),
                        list_sdvs.str_element(plain_string2)
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of_multi(
                'plain strings on several lines (separated by continuation token) / first line empty',
                [
                    ContinuationTokenFollowedByArgumentAbsStx(
                        ArgumentOfRichStringAbsStx.of_str(plain_string1)),
                    ArgumentOfRichStringAbsStx.of_str(plain_string2),
                ], ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[
                        list_sdvs.str_element(plain_string1),
                        list_sdvs.str_element(plain_string2)
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of_multi(
                'symbol reference + plain string + until-end-of-line', [
                    ArgumentOfSymbolReferenceAbsStx(symbol_name_1),
                    ArgumentOfRichStringAbsStx.of_str(plain_string1),
                    ArgumentOfRichStringAbsStx.of_str_until_eol(
                        remaining_part_of_current_line_with_sym_ref),
                ],
                Arrangement(
                    SymbolContext.symbol_table_of_contexts([
                        StringSymbolContext.of_arbitrary_value(symbol_name_1),
                        StringSymbolContext.of_arbitrary_value(symbol_name_2),
                    ])),
                Expectation(
                    elements=[
                        list_sdvs.symbol_element(
                            reference_to__on_direct_and_indirect(
                                symbol_name_1)),
                        list_sdvs.str_element(plain_string1),
                        list_sdvs.string_element(
                            string_sdvs.from_fragments([
                                string_sdvs.str_fragment('before'),
                                string_sdvs.symbol_fragment(
                                    reference_to__on_direct_and_indirect(
                                        symbol_name_2)),
                                string_sdvs.str_fragment('after'),
                            ]))
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.matches_sequence([
                        asrt_sym_ref.matches_reference_2(
                            symbol_name_1,
                            asrt_data_rest.is__w_str_rendering()),
                        asrt_sym_ref.matches_reference_2(
                            symbol_name_2,
                            asrt_data_rest.is__w_str_rendering()),
                    ]),
                )),
        ]
        # ACT & ASSERT #
        _test_cases_w_source_variants(self, cases)
Exemple #22
0
 def test_string_constant_SHOULD_raise_exception(self):
     fragment = impl.SymbolStringFragmentSdv(
         data_references.reference_to__on_direct_and_indirect(
             'the_symbol_name'))
     with self.assertRaises(ValueError):
         fragment.string_constant
Exemple #23
0
 def test_should_be_string_constant(self):
     fragment = impl.SymbolStringFragmentSdv(
         data_references.reference_to__on_direct_and_indirect(
             'the_symbol_name'))
     self.assertFalse(fragment.is_string_constant)
Exemple #24
0
 def test(self):
     single_token_value = 'single_token_value'
     single_token_value_1 = 'single_token_value_1'
     single_token_value_2 = 'single_token_value_2'
     symbol_name = 'a_symbol_name'
     cases = [
         Case(
             'multiple string constants on line that is the last line',
             source=remaining_source(single_token_value_1 + ' ' +
                                     single_token_value_2),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element(single_token_value_1),
                     list_sdvs.str_element(single_token_value_2)
                 ],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'multiple string constants on line that is followed by an empty line',
             source=remaining_source(
                 single_token_value_1 + ' ' + single_token_value_2, ['']),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element(single_token_value_1),
                     list_sdvs.str_element(single_token_value_2)
                 ],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'multiple string constants on line that is followed by a non-empty line',
             source=remaining_source(
                 single_token_value_1 + ' ' + single_token_value_2, ['  ']),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element(single_token_value_1),
                     list_sdvs.str_element(single_token_value_2)
                 ],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'symbol-reference and string constant on first line',
             source=remaining_source('{sym_ref} {string_constant}'.format(
                 sym_ref=symbol_reference_syntax_for_name(symbol_name),
                 string_constant=single_token_value)),
             expectation=Expectation(
                 elements=[
                     list_sdvs.symbol_element(
                         reference_to__on_direct_and_indirect(symbol_name)),
                     list_sdvs.str_element(single_token_value)
                 ],
                 references=asrt.matches_sequence([
                     asrt_sym_ref.matches_reference_2(
                         symbol_name, asrt_data_rest.is__w_str_rendering())
                 ]),
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'complex element (sym-ref and str const) and string constant, '
             'followed by space, '
             'followed by non-empty line',
             source=remaining_source(
                 symbol_reference_syntax_for_name(symbol_name) +
                 single_token_value + ' ' + single_token_value_1, ['   ']),
             expectation=Expectation(
                 elements=[
                     list_sdvs.string_element(
                         string_sdvs.from_fragments(
                             [
                                 string_sdvs.symbol_fragment(
                                     SymbolReference(
                                         symbol_name,
                                         reference_restrictions.
                                         is_any_type_w_str_rendering()), ),
                                 string_sdvs.str_fragment(
                                     single_token_value),
                             ])),
                     list_sdvs.str_element(single_token_value_1),
                 ],
                 references=asrt.matches_sequence([
                     asrt_sym_ref.matches_reference_2(
                         symbol_name, asrt_data_rest.is__w_str_rendering())
                 ]),
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'multiple string constants on line followed by r-paren',
             source=remaining_source(
                 ' '.join((single_token_value_1, single_token_value_2,
                           reserved_words.PAREN_END, 'constant')), ['  ']),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element(single_token_value_1),
                     list_sdvs.str_element(single_token_value_2)
                 ],
                 source=asrt_source.source_is_not_at_end(
                     current_line_number=asrt.equals(1),
                     remaining_part_of_current_line=asrt.equals(' '.join(
                         (reserved_words.PAREN_END, 'constant'))))),
         ),
         Case(
             '1st string on first line, followed by continuation-token, followed by line with 2nd string',
             source=remaining_source(
                 single_token_value_1 + ' ' + defs.CONTINUATION_TOKEN,
                 [single_token_value_2]),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element(single_token_value_1),
                     list_sdvs.str_element(single_token_value_2)
                 ],
                 source=asrt_source.is_at_end_of_line(2)),
         ),
         Case(
             'multiple elements on two lines, separated by continuation token',
             source=remaining_source('a b ' + defs.CONTINUATION_TOKEN,
                                     ['  c d  ']),
             expectation=Expectation(
                 elements=[
                     list_sdvs.str_element('a'),
                     list_sdvs.str_element('b'),
                     list_sdvs.str_element('c'),
                     list_sdvs.str_element('d'),
                 ],
                 source=asrt_source.is_at_end_of_line(2)),
         ),
     ]
     # ACT & ASSERT #
     _test_cases(self, cases)
Exemple #25
0
    def test_remaining_part_of_current_line_as_literal(self):
        # ARRANGE #
        symbol_name = 'symbol_name'
        str_with_space_and_invalid_token_syntax = 'before and after space, ' + SOFT_QUOTE_CHAR + 'after quote'

        cases = [
            Case.of(
                'string with one space after marker, and no space at EOL',
                ArgumentOfRichStringAbsStx.of_str_until_eol(
                    str_with_space_and_invalid_token_syntax),
                ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[
                        list_sdvs.str_element(
                            str_with_space_and_invalid_token_syntax)
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of(
                'with surrounding space',
                ArgumentOfRichStringAbsStx.of_str_until_eol(
                    '   ' + str_with_space_and_invalid_token_syntax + '  \t '),
                ARRANGEMENT__NEUTRAL,
                Expectation(
                    elements=[
                        list_sdvs.str_element(
                            str_with_space_and_invalid_token_syntax)
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.is_empty_sequence,
                )),
            Case.of(
                'with symbol reference',
                ArgumentOfRichStringAbsStx.of_str_until_eol(''.join([
                    'before',
                    symbol_reference_syntax_for_name(symbol_name), 'after'
                ])),
                Arrangement(
                    StringSymbolContext.of_arbitrary_value(
                        symbol_name).symbol_table),
                Expectation(
                    elements=[
                        list_sdvs.string_element(
                            string_sdvs.from_fragments([
                                string_sdvs.str_fragment('before'),
                                string_sdvs.symbol_fragment(
                                    reference_to__on_direct_and_indirect(
                                        symbol_name)),
                                string_sdvs.str_fragment('after'),
                            ]))
                    ],
                    validators=asrt.is_empty_sequence,
                    references=asrt.matches_sequence([
                        asrt_sym_ref.matches_reference_2(
                            symbol_name, asrt_data_rest.is__w_str_rendering())
                    ]),
                )),
        ]
        # ACT & ASSERT #
        _test_cases_w_source_variants(self, cases)
Exemple #26
0
 def test(self):
     single_token_value = 'single_token_value'
     string_symbol = NameAndValue('string_symbol_name',
                                  'string symbol value')
     cases = [
         Case(
             'single string constant, at end of line, on the last line',
             source=remaining_source(single_token_value),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=assert_source(is_at_eof=asrt.is_true)),
         ),
         Case(
             'single symbol reference, at end of line, on the last line',
             source=remaining_source(
                 symbol_reference_syntax_for_name(string_symbol.name)),
             expectation=Expectation(
                 elements=[
                     list_sdvs.symbol_element(
                         reference_to__on_direct_and_indirect(
                             string_symbol.name))
                 ],
                 source=assert_source(is_at_eof=asrt.is_true),
                 references=asrt.matches_sequence([
                     asrt_sym_ref.matches_reference_2(
                         string_symbol.name,
                         asrt_data_rest.is__w_str_rendering())
                 ])),
         ),
         Case(
             'complex element (str const and sym-refs), at end of line, on the last line',
             source=remaining_source(
                 single_token_value +
                 symbol_reference_syntax_for_name(string_symbol.name)),
             expectation=Expectation(
                 elements=[
                     list_sdvs.string_element(
                         string_sdvs.from_fragments(
                             [
                                 string_sdvs.str_fragment(
                                     single_token_value),
                                 string_sdvs.symbol_fragment(
                                     SymbolReference(
                                         string_symbol.name,
                                         reference_restrictions.
                                         is_any_type_w_str_rendering(),
                                     )),
                             ]))
                 ],
                 references=asrt.matches_sequence([
                     asrt_sym_ref.matches_reference_2(
                         string_symbol.name,
                         asrt_data_rest.is__w_str_rendering())
                 ]),
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, followed by more than one space, on the last line',
             source=remaining_source(single_token_value + '  ', []),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, followed by single space, on the last line',
             source=remaining_source(single_token_value + ' ', []),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, followed by space, followed by empty line',
             source=remaining_source(single_token_value + '  ', ['']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, at end of line, followed by line with only space',
             source=remaining_source(single_token_value, ['   ']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, followed by space, followed by line with only space',
             source=remaining_source(single_token_value + '  ', ['   ']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'single element, at end of line, followed by line with invalid quoting',
             source=remaining_source(single_token_value, ['"   ']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(1)),
         ),
         Case(
             'continuation token, followed by line with single element',
             source=remaining_source(defs.CONTINUATION_TOKEN,
                                     [single_token_value]),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(2)),
         ),
         Case(
             'single element, followed by continuation token, followed by empty line',
             source=remaining_source(
                 single_token_value + ' ' + defs.CONTINUATION_TOKEN, ['']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.is_at_end_of_line(2)),
         ),
         Case(
             'single element, followed by r-paren and more',
             source=remaining_source(
                 ' '.join((single_token_value, reserved_words.PAREN_END,
                           'const_str')), ['"   ']),
             expectation=Expectation(
                 elements=[list_sdvs.str_element(single_token_value)],
                 source=asrt_source.source_is_not_at_end(
                     current_line_number=asrt.equals(1),
                     remaining_part_of_current_line=asrt.equals(' '.join(
                         (reserved_words.PAREN_END, 'const_str'))))),
         ),
     ]
     # ACT & ASSERT #
     _test_cases(self, cases)