rkoans 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/CURRICULUM.md +86 -0
- data/README.md +77 -0
- data/THIRD_PARTY_NOTICES.md +30 -0
- data/exercises/about-array-assignment/about_array_assignment.rb +45 -0
- data/exercises/about-array-assignment/brief.md +11 -0
- data/exercises/about-array-assignment/hint.md +11 -0
- data/exercises/about-arrays/about_arrays.rb +77 -0
- data/exercises/about-arrays/brief.md +16 -0
- data/exercises/about-arrays/hint.md +13 -0
- data/exercises/about-asserts/about_asserts.rb +22 -0
- data/exercises/about-asserts/brief.md +22 -0
- data/exercises/about-asserts/hint.md +10 -0
- data/exercises/about-blocks/about_blocks.rb +76 -0
- data/exercises/about-blocks/brief.md +44 -0
- data/exercises/about-blocks/hint.md +7 -0
- data/exercises/about-class-methods/about_class_methods.rb +105 -0
- data/exercises/about-class-methods/brief.md +73 -0
- data/exercises/about-class-methods/hint.md +8 -0
- data/exercises/about-classes/about_classes.rb +131 -0
- data/exercises/about-classes/brief.md +73 -0
- data/exercises/about-classes/hint.md +7 -0
- data/exercises/about-constants/about_constants.rb +49 -0
- data/exercises/about-constants/brief.md +51 -0
- data/exercises/about-constants/hint.md +7 -0
- data/exercises/about-control-statements/about_control_statements.rb +152 -0
- data/exercises/about-control-statements/brief.md +9 -0
- data/exercises/about-control-statements/hint.md +7 -0
- data/exercises/about-dice-project/about_dice_project.rb +27 -0
- data/exercises/about-dice-project/brief.md +12 -0
- data/exercises/about-dice-project/hint.md +5 -0
- data/exercises/about-exceptions/about_exceptions.rb +84 -0
- data/exercises/about-exceptions/brief.md +19 -0
- data/exercises/about-exceptions/hint.md +8 -0
- data/exercises/about-extra-credit/about_extra_credit.rb +117 -0
- data/exercises/about-extra-credit/brief.md +28 -0
- data/exercises/about-extra-credit/hint.md +5 -0
- data/exercises/about-hashes/about_hashes.rb +160 -0
- data/exercises/about-hashes/brief.md +9 -0
- data/exercises/about-hashes/hint.md +8 -0
- data/exercises/about-inheritance/about_inheritance.rb +63 -0
- data/exercises/about-inheritance/brief.md +50 -0
- data/exercises/about-inheritance/hint.md +8 -0
- data/exercises/about-iteration/about_iteration.rb +96 -0
- data/exercises/about-iteration/brief.md +26 -0
- data/exercises/about-iteration/hint.md +6 -0
- data/exercises/about-keyword-arguments/about_keyword_arguments.rb +56 -0
- data/exercises/about-keyword-arguments/brief.md +28 -0
- data/exercises/about-keyword-arguments/hint.md +7 -0
- data/exercises/about-message-passing/about_message_passing.rb +112 -0
- data/exercises/about-message-passing/brief.md +59 -0
- data/exercises/about-message-passing/hint.md +8 -0
- data/exercises/about-methods/about_methods.rb +104 -0
- data/exercises/about-methods/brief.md +55 -0
- data/exercises/about-methods/hint.md +8 -0
- data/exercises/about-modules/about_modules.rb +43 -0
- data/exercises/about-modules/brief.md +44 -0
- data/exercises/about-modules/hint.md +8 -0
- data/exercises/about-nil/about_nil.rb +29 -0
- data/exercises/about-nil/brief.md +12 -0
- data/exercises/about-nil/hint.md +11 -0
- data/exercises/about-objects/about_objects.rb +51 -0
- data/exercises/about-objects/brief.md +14 -0
- data/exercises/about-objects/hint.md +12 -0
- data/exercises/about-open-classes/about_open_classes.rb +38 -0
- data/exercises/about-open-classes/brief.md +34 -0
- data/exercises/about-open-classes/hint.md +7 -0
- data/exercises/about-pattern-matching/about_pattern_matching.rb +106 -0
- data/exercises/about-pattern-matching/brief.md +124 -0
- data/exercises/about-pattern-matching/hint.md +8 -0
- data/exercises/about-proxy-object-project/about_proxy_object_project.rb +43 -0
- data/exercises/about-proxy-object-project/brief.md +10 -0
- data/exercises/about-proxy-object-project/hint.md +5 -0
- data/exercises/about-regular-expressions/about_regular_expressions.rb +174 -0
- data/exercises/about-regular-expressions/brief.md +9 -0
- data/exercises/about-regular-expressions/hint.md +8 -0
- data/exercises/about-sandwich-code/about_sandwich_code.rb +58 -0
- data/exercises/about-sandwich-code/brief.md +14 -0
- data/exercises/about-sandwich-code/hint.md +5 -0
- data/exercises/about-scope/about_scope.rb +76 -0
- data/exercises/about-scope/brief.md +35 -0
- data/exercises/about-scope/hint.md +8 -0
- data/exercises/about-scoring-project/about_scoring_project.rb +16 -0
- data/exercises/about-scoring-project/brief.md +10 -0
- data/exercises/about-scoring-project/hint.md +5 -0
- data/exercises/about-strings/about_strings.rb +142 -0
- data/exercises/about-strings/brief.md +22 -0
- data/exercises/about-strings/hint.md +11 -0
- data/exercises/about-symbols/about_symbols.rb +53 -0
- data/exercises/about-symbols/brief.md +21 -0
- data/exercises/about-symbols/hint.md +12 -0
- data/exercises/about-to-str/about_to_str.rb +49 -0
- data/exercises/about-to-str/brief.md +37 -0
- data/exercises/about-to-str/hint.md +7 -0
- data/exercises/about-triangle-project/about_triangle_project.rb +15 -0
- data/exercises/about-triangle-project/brief.md +11 -0
- data/exercises/about-triangle-project/hint.md +5 -0
- data/exercises/about-triangle-project-two/about_triangle_project_two.rb +22 -0
- data/exercises/about-triangle-project-two/brief.md +10 -0
- data/exercises/about-triangle-project-two/hint.md +5 -0
- data/exercises/about-true-and-false/about_true_and_false.rb +26 -0
- data/exercises/about-true-and-false/brief.md +22 -0
- data/exercises/about-true-and-false/hint.md +7 -0
- data/exercises/blocks-and-methods/blocks_and_methods.rb +14 -0
- data/exercises/blocks-and-methods/brief.md +8 -0
- data/exercises/blocks-and-methods/hint.md +6 -0
- data/exercises/catalog.json +61 -0
- data/exercises/class-state/brief.md +8 -0
- data/exercises/class-state/class_state.rb +39 -0
- data/exercises/class-state/hint.md +5 -0
- data/exercises/closure-capture/brief.md +8 -0
- data/exercises/closure-capture/closure_capture.rb +21 -0
- data/exercises/closure-capture/hint.md +5 -0
- data/exercises/collection-basics/brief.md +8 -0
- data/exercises/collection-basics/collection_basics.rb +16 -0
- data/exercises/collection-basics/hint.md +6 -0
- data/exercises/constant-scope/brief.md +8 -0
- data/exercises/constant-scope/constant_scope.rb +18 -0
- data/exercises/constant-scope/hint.md +5 -0
- data/exercises/core-protocols/brief.md +8 -0
- data/exercises/core-protocols/core_protocols.rb +43 -0
- data/exercises/core-protocols/hint.md +5 -0
- data/exercises/delegation/brief.md +8 -0
- data/exercises/delegation/delegation.rb +20 -0
- data/exercises/delegation/hint.md +5 -0
- data/exercises/dynamic-methods/brief.md +8 -0
- data/exercises/dynamic-methods/dynamic_methods.rb +33 -0
- data/exercises/dynamic-methods/hint.md +5 -0
- data/exercises/exception-flow/brief.md +8 -0
- data/exercises/exception-flow/exception_flow.rb +27 -0
- data/exercises/exception-flow/hint.md +5 -0
- data/exercises/heredoc-layout/brief.md +14 -0
- data/exercises/heredoc-layout/heredoc_layout.rb +25 -0
- data/exercises/heredoc-layout/hint.md +9 -0
- data/exercises/keyword-forwarding/brief.md +8 -0
- data/exercises/keyword-forwarding/hint.md +5 -0
- data/exercises/keyword-forwarding/keyword_forwarding.rb +27 -0
- data/exercises/lazy-enumeration/brief.md +8 -0
- data/exercises/lazy-enumeration/hint.md +5 -0
- data/exercises/lazy-enumeration/lazy_enumeration.rb +16 -0
- data/exercises/literals-and-operators/brief.md +20 -0
- data/exercises/literals-and-operators/hint.md +5 -0
- data/exercises/literals-and-operators/literals_and_operators.rb +15 -0
- data/exercises/method-contracts/brief.md +8 -0
- data/exercises/method-contracts/hint.md +5 -0
- data/exercises/method-contracts/method_contracts.rb +22 -0
- data/exercises/method-lookup/brief.md +8 -0
- data/exercises/method-lookup/hint.md +5 -0
- data/exercises/method-lookup/method_lookup.rb +26 -0
- data/exercises/nonlocal-exit/brief.md +8 -0
- data/exercises/nonlocal-exit/hint.md +5 -0
- data/exercises/nonlocal-exit/nonlocal_exit.rb +29 -0
- data/exercises/numbered-parameters/brief.md +18 -0
- data/exercises/numbered-parameters/hint.md +5 -0
- data/exercises/numbered-parameters/numbered_parameters.rb +18 -0
- data/exercises/numeric-precision/brief.md +8 -0
- data/exercises/numeric-precision/hint.md +5 -0
- data/exercises/numeric-precision/numeric_precision.rb +17 -0
- data/exercises/pattern-matching/brief.md +8 -0
- data/exercises/pattern-matching/hint.md +5 -0
- data/exercises/pattern-matching/pattern_matching.rb +22 -0
- data/exercises/refinement-scope/brief.md +8 -0
- data/exercises/refinement-scope/hint.md +5 -0
- data/exercises/refinement-scope/refinement_scope.rb +33 -0
- data/exercises/regexp-captures/brief.md +8 -0
- data/exercises/regexp-captures/hint.md +5 -0
- data/exercises/regexp-captures/regexp_captures.rb +25 -0
- data/exercises/runtime-context/brief.md +20 -0
- data/exercises/runtime-context/hint.md +8 -0
- data/exercises/runtime-context/runtime_context.rb +11 -0
- data/exercises/shared-rows/brief.md +8 -0
- data/exercises/shared-rows/hint.md +7 -0
- data/exercises/shared-rows/shared_rows.rb +13 -0
- data/exercises/singleton-pattern/brief.md +8 -0
- data/exercises/singleton-pattern/hint.md +5 -0
- data/exercises/singleton-pattern/singleton_pattern.rb +20 -0
- data/exercises/time-and-date/brief.md +8 -0
- data/exercises/time-and-date/hint.md +5 -0
- data/exercises/time-and-date/time_and_date.rb +21 -0
- data/exercises/visibility/brief.md +8 -0
- data/exercises/visibility/hint.md +5 -0
- data/exercises/visibility/visibility.rb +32 -0
- data/lib/rkoans/catalog.rb +31 -0
- data/lib/rkoans/checker.rb +62 -0
- data/lib/rkoans/cli.rb +79 -0
- data/lib/rkoans/error.rb +6 -0
- data/lib/rkoans/exercise.rb +50 -0
- data/lib/rkoans/keyboard.rb +51 -0
- data/lib/rkoans/progress.rb +39 -0
- data/lib/rkoans/selection.rb +31 -0
- data/lib/rkoans/session.rb +127 -0
- data/lib/rkoans/terminal_view.rb +99 -0
- data/lib/rkoans/version.rb +1 -1
- data/lib/rkoans/watcher.rb +58 -0
- data/lib/rkoans.rb +13 -3
- data/sig/about_array_assignment_acceptance_test.rbs +3 -0
- data/sig/about_arrays_acceptance_test.rbs +3 -0
- data/sig/about_asserts_command_test.rbs +4 -0
- data/sig/about_blocks_acceptance_test.rbs +3 -0
- data/sig/about_class_methods_acceptance_test.rbs +3 -0
- data/sig/about_classes_acceptance_test.rbs +3 -0
- data/sig/about_constants_acceptance_test.rbs +3 -0
- data/sig/about_control_statements_acceptance_test.rbs +3 -0
- data/sig/about_dice_project_acceptance_test.rbs +3 -0
- data/sig/about_exceptions_acceptance_test.rbs +3 -0
- data/sig/about_extra_credit_acceptance_test.rbs +5 -0
- data/sig/about_hashes_acceptance_test.rbs +3 -0
- data/sig/about_inheritance_acceptance_test.rbs +3 -0
- data/sig/about_iteration_acceptance_test.rbs +3 -0
- data/sig/about_keyword_arguments_acceptance_test.rbs +3 -0
- data/sig/about_message_passing_acceptance_test.rbs +3 -0
- data/sig/about_methods_acceptance_test.rbs +3 -0
- data/sig/about_modules_acceptance_test.rbs +3 -0
- data/sig/about_nil_acceptance_test.rbs +3 -0
- data/sig/about_objects_acceptance_test.rbs +3 -0
- data/sig/about_open_classes_acceptance_test.rbs +3 -0
- data/sig/about_pattern_matching_acceptance_test.rbs +3 -0
- data/sig/about_proxy_object_project_acceptance_test.rbs +3 -0
- data/sig/about_regular_expressions_acceptance_test.rbs +3 -0
- data/sig/about_sandwich_code_acceptance_test.rbs +3 -0
- data/sig/about_scope_acceptance_test.rbs +3 -0
- data/sig/about_scoring_project_acceptance_test.rbs +3 -0
- data/sig/about_strings_acceptance_test.rbs +3 -0
- data/sig/about_symbols_acceptance_test.rbs +3 -0
- data/sig/about_to_str_acceptance_test.rbs +3 -0
- data/sig/about_triangle_project_acceptance_test.rbs +3 -0
- data/sig/about_triangle_project_two_acceptance_test.rbs +3 -0
- data/sig/about_true_and_false_command_test.rbs +4 -0
- data/sig/catalog_error_command_test.rbs +4 -0
- data/sig/checker_test.rbs +9 -0
- data/sig/class_state_acceptance_test.rbs +3 -0
- data/sig/closure_capture_acceptance_test.rbs +3 -0
- data/sig/command_support.rbs +18 -0
- data/sig/command_test.rbs +5 -0
- data/sig/constant_scope_acceptance_test.rbs +3 -0
- data/sig/core_protocols_acceptance_test.rbs +3 -0
- data/sig/curriculum_cop_test.rbs +9 -0
- data/sig/delegation_acceptance_test.rbs +3 -0
- data/sig/dynamic_methods_acceptance_test.rbs +3 -0
- data/sig/exception_flow_acceptance_test.rbs +3 -0
- data/sig/exercise_test.rbs +3 -0
- data/sig/exercises/about_array_assignment.rbs +36 -0
- data/sig/exercises/about_arrays.rbs +51 -0
- data/sig/exercises/about_asserts.rbs +23 -0
- data/sig/exercises/about_blocks.rbs +40 -0
- data/sig/exercises/about_class_methods.rbs +62 -0
- data/sig/exercises/about_classes.rbs +88 -0
- data/sig/exercises/about_constants.rbs +53 -0
- data/sig/exercises/about_control_statements.rbs +46 -0
- data/sig/exercises/about_dice_project.rbs +16 -0
- data/sig/exercises/about_exceptions.rbs +36 -0
- data/sig/exercises/about_extra_credit.rbs +36 -0
- data/sig/exercises/about_hashes.rbs +62 -0
- data/sig/exercises/about_inheritance.rbs +50 -0
- data/sig/exercises/about_iteration.rbs +37 -0
- data/sig/exercises/about_keyword_arguments.rbs +33 -0
- data/sig/exercises/about_message_passing.rbs +68 -0
- data/sig/exercises/about_methods.rbs +68 -0
- data/sig/exercises/about_modules.rbs +38 -0
- data/sig/exercises/about_nil.rbs +23 -0
- data/sig/exercises/about_objects.rbs +38 -0
- data/sig/exercises/about_open_classes.rbs +31 -0
- data/sig/exercises/about_pattern_matching.rbs +65 -0
- data/sig/exercises/about_proxy_object_project.rbs +31 -0
- data/sig/exercises/about_regular_expressions.rbs +83 -0
- data/sig/exercises/about_sandwich_code.rbs +17 -0
- data/sig/exercises/about_scope.rbs +59 -0
- data/sig/exercises/about_scoring_project.rbs +16 -0
- data/sig/exercises/about_strings.rbs +85 -0
- data/sig/exercises/about_symbols.rbs +46 -0
- data/sig/exercises/about_to_str.rbs +36 -0
- data/sig/exercises/about_triangle_project.rbs +11 -0
- data/sig/exercises/about_triangle_project_two.rbs +12 -0
- data/sig/exercises/about_true_and_false.rbs +27 -0
- data/sig/exercises/blocks_and_methods.rbs +11 -0
- data/sig/exercises/class_state.rbs +19 -0
- data/sig/exercises/closure_capture.rbs +10 -0
- data/sig/exercises/collection_basics.rbs +6 -0
- data/sig/exercises/collection_basics_test.rbs +4 -0
- data/sig/exercises/constant_scope.rbs +11 -0
- data/sig/exercises/core_protocols.rbs +20 -0
- data/sig/exercises/delegation.rbs +14 -0
- data/sig/exercises/dynamic_methods.rbs +13 -0
- data/sig/exercises/exception_flow.rbs +11 -0
- data/sig/exercises/heredoc_layout.rbs +11 -0
- data/sig/exercises/keyword_forwarding.rbs +12 -0
- data/sig/exercises/lazy_enumeration.rbs +10 -0
- data/sig/exercises/literals_and_operators.rbs +12 -0
- data/sig/exercises/method_contracts.rbs +11 -0
- data/sig/exercises/method_lookup.rbs +16 -0
- data/sig/exercises/nonlocal_exit.rbs +14 -0
- data/sig/exercises/numbered_parameters.rbs +11 -0
- data/sig/exercises/numeric_precision.rbs +11 -0
- data/sig/exercises/pattern_matching.rbs +10 -0
- data/sig/exercises/refinement_scope.rbs +18 -0
- data/sig/exercises/regexp_captures.rbs +11 -0
- data/sig/exercises/runtime_context.rbs +23 -0
- data/sig/exercises/shared_rows.rbs +11 -0
- data/sig/exercises/singleton_pattern.rbs +14 -0
- data/sig/exercises/time_and_date.rbs +11 -0
- data/sig/exercises/visibility.rbs +18 -0
- data/sig/fixture_support.rbs +11 -0
- data/sig/help_hint_command_test.rbs +8 -0
- data/sig/heredoc_layout_acceptance_test.rbs +3 -0
- data/sig/keyboard_session_test.rbs +9 -0
- data/sig/keyword_forwarding_acceptance_test.rbs +3 -0
- data/sig/lazy_enumeration_acceptance_test.rbs +3 -0
- data/sig/literals_and_operators_acceptance_test.rbs +3 -0
- data/sig/method_contracts_acceptance_test.rbs +3 -0
- data/sig/method_lookup_acceptance_test.rbs +3 -0
- data/sig/nonlocal_exit_acceptance_test.rbs +3 -0
- data/sig/numbered_parameters_acceptance_test.rbs +3 -0
- data/sig/numeric_precision_acceptance_test.rbs +4 -0
- data/sig/packaging_test.rbs +3 -0
- data/sig/pattern_matching_acceptance_test.rbs +3 -0
- data/sig/reference_solutions_test.rbs +3 -0
- data/sig/refinement_scope_acceptance_test.rbs +3 -0
- data/sig/regexp_captures_acceptance_test.rbs +4 -0
- data/sig/rkoans/catalog.rbs +11 -0
- data/sig/rkoans/checker.rbs +22 -0
- data/sig/rkoans/cli.rbs +21 -0
- data/sig/rkoans/exercise.rbs +18 -0
- data/sig/rkoans/keyboard.rbs +13 -0
- data/sig/rkoans/progress.rbs +9 -0
- data/sig/rkoans/selection.rbs +9 -0
- data/sig/rkoans/session.rbs +30 -0
- data/sig/rkoans/terminal_view.rbs +24 -0
- data/sig/rkoans/watcher.rbs +18 -0
- data/sig/rkoans.rbs +2 -0
- data/sig/runtime_context_command_test.rbs +4 -0
- data/sig/selection_command_test.rbs +5 -0
- data/sig/session_command_test.rbs +12 -0
- data/sig/session_edge_cases_test.rbs +4 -0
- data/sig/shared_rows_acceptance_test.rbs +3 -0
- data/sig/singleton_pattern_acceptance_test.rbs +3 -0
- data/sig/time_and_date_acceptance_test.rbs +4 -0
- data/sig/visibility_acceptance_test.rbs +4 -0
- data/sig/watcher_test.rbs +3 -0
- data/solutions/about-array-assignment/about_array_assignment.rb +36 -0
- data/solutions/about-arrays/about_arrays.rb +53 -0
- data/solutions/about-asserts/about_asserts.rb +22 -0
- data/solutions/about-blocks/about_blocks.rb +30 -0
- data/solutions/about-class-methods/about_class_methods.rb +36 -0
- data/solutions/about-classes/about_classes.rb +40 -0
- data/solutions/about-constants/about_constants.rb +26 -0
- data/solutions/about-control-statements/about_control_statements.rb +35 -0
- data/solutions/about-dice-project/about_dice_project.rb +27 -0
- data/solutions/about-exceptions/about_exceptions.rb +30 -0
- data/solutions/about-extra-credit/about_extra_credit.rb +114 -0
- data/solutions/about-hashes/about_hashes.rb +52 -0
- data/solutions/about-inheritance/about_inheritance.rb +27 -0
- data/solutions/about-iteration/about_iteration.rb +31 -0
- data/solutions/about-keyword-arguments/about_keyword_arguments.rb +28 -0
- data/solutions/about-message-passing/about_message_passing.rb +38 -0
- data/solutions/about-methods/about_methods.rb +39 -0
- data/solutions/about-modules/about_modules.rb +23 -0
- data/solutions/about-nil/about_nil.rb +23 -0
- data/solutions/about-objects/about_objects.rb +34 -0
- data/solutions/about-open-classes/about_open_classes.rb +23 -0
- data/solutions/about-pattern-matching/about_pattern_matching.rb +39 -0
- data/solutions/about-proxy-object-project/about_proxy_object_project.rb +44 -0
- data/solutions/about-regular-expressions/about_regular_expressions.rb +60 -0
- data/solutions/about-sandwich-code/about_sandwich_code.rb +60 -0
- data/solutions/about-scope/about_scope.rb +33 -0
- data/solutions/about-scoring-project/about_scoring_project.rb +19 -0
- data/solutions/about-strings/about_strings.rb +56 -0
- data/solutions/about-symbols/about_symbols.rb +35 -0
- data/solutions/about-to-str/about_to_str.rb +24 -0
- data/solutions/about-triangle-project/about_triangle_project.rb +19 -0
- data/solutions/about-triangle-project-two/about_triangle_project_two.rb +25 -0
- data/solutions/about-true-and-false/about_true_and_false.rb +25 -0
- data/solutions/blocks-and-methods/blocks_and_methods.rb +14 -0
- data/solutions/class-state/class_state.rb +33 -0
- data/solutions/closure-capture/closure_capture.rb +12 -0
- data/solutions/collection-basics/collection_basics.rb +14 -0
- data/solutions/constant-scope/constant_scope.rb +18 -0
- data/solutions/core-protocols/core_protocols.rb +44 -0
- data/solutions/delegation/delegation.rb +17 -0
- data/solutions/dynamic-methods/dynamic_methods.rb +32 -0
- data/solutions/exception-flow/exception_flow.rb +34 -0
- data/solutions/heredoc-layout/heredoc_layout.rb +24 -0
- data/solutions/keyword-forwarding/keyword_forwarding.rb +26 -0
- data/solutions/lazy-enumeration/lazy_enumeration.rb +11 -0
- data/solutions/literals-and-operators/literals_and_operators.rb +22 -0
- data/solutions/method-contracts/method_contracts.rb +18 -0
- data/solutions/method-lookup/method_lookup.rb +26 -0
- data/solutions/nonlocal-exit/nonlocal_exit.rb +46 -0
- data/solutions/numbered-parameters/numbered_parameters.rb +18 -0
- data/solutions/numeric-precision/numeric_precision.rb +17 -0
- data/solutions/pattern-matching/pattern_matching.rb +17 -0
- data/solutions/refinement-scope/refinement_scope.rb +34 -0
- data/solutions/regexp-captures/regexp_captures.rb +24 -0
- data/solutions/runtime-context/runtime_context.rb +19 -0
- data/solutions/shared-rows/shared_rows.rb +13 -0
- data/solutions/singleton-pattern/singleton_pattern.rb +19 -0
- data/solutions/time-and-date/time_and_date.rb +16 -0
- data/solutions/visibility/visibility.rb +34 -0
- data/test/exercises/about_array_assignment_test.rb +87 -0
- data/test/exercises/about_arrays_test.rb +119 -0
- data/test/exercises/about_asserts_test.rb +41 -0
- data/test/exercises/about_blocks_test.rb +140 -0
- data/test/exercises/about_class_methods_test.rb +232 -0
- data/test/exercises/about_classes_test.rb +261 -0
- data/test/exercises/about_constants_test.rb +111 -0
- data/test/exercises/about_control_statements_test.rb +188 -0
- data/test/exercises/about_dice_project_test.rb +40 -0
- data/test/exercises/about_exceptions_test.rb +98 -0
- data/test/exercises/about_extra_credit_test.rb +74 -0
- data/test/exercises/about_hashes_test.rb +163 -0
- data/test/exercises/about_inheritance_test.rb +121 -0
- data/test/exercises/about_iteration_test.rb +148 -0
- data/test/exercises/about_keyword_arguments_test.rb +80 -0
- data/test/exercises/about_message_passing_test.rb +230 -0
- data/test/exercises/about_methods_test.rb +208 -0
- data/test/exercises/about_modules_test.rb +98 -0
- data/test/exercises/about_nil_test.rb +35 -0
- data/test/exercises/about_objects_test.rb +74 -0
- data/test/exercises/about_open_classes_test.rb +60 -0
- data/test/exercises/about_pattern_matching_test.rb +257 -0
- data/test/exercises/about_proxy_object_project_test.rb +75 -0
- data/test/exercises/about_regular_expressions_test.rb +243 -0
- data/test/exercises/about_sandwich_code_test.rb +82 -0
- data/test/exercises/about_scope_test.rb +123 -0
- data/test/exercises/about_scoring_project_test.rb +62 -0
- data/test/exercises/about_strings_test.rb +255 -0
- data/test/exercises/about_symbols_test.rb +120 -0
- data/test/exercises/about_to_str_test.rb +89 -0
- data/test/exercises/about_triangle_project_test.rb +29 -0
- data/test/exercises/about_triangle_project_two_test.rb +28 -0
- data/test/exercises/about_true_and_false_test.rb +43 -0
- data/test/exercises/blocks_and_methods_test.rb +22 -0
- data/test/exercises/class_state_test.rb +29 -0
- data/test/exercises/closure_capture_test.rb +29 -0
- data/test/exercises/collection_basics_test.rb +18 -0
- data/test/exercises/constant_scope_test.rb +18 -0
- data/test/exercises/core_protocols_test.rb +28 -0
- data/test/exercises/delegation_test.rb +23 -0
- data/test/exercises/dynamic_methods_test.rb +28 -0
- data/test/exercises/exception_flow_test.rb +17 -0
- data/test/exercises/heredoc_layout_test.rb +18 -0
- data/test/exercises/keyword_forwarding_test.rb +22 -0
- data/test/exercises/lazy_enumeration_test.rb +15 -0
- data/test/exercises/literals_and_operators_test.rb +25 -0
- data/test/exercises/method_contracts_test.rb +28 -0
- data/test/exercises/method_lookup_test.rb +14 -0
- data/test/exercises/nonlocal_exit_test.rb +22 -0
- data/test/exercises/numbered_parameters_test.rb +15 -0
- data/test/exercises/numeric_precision_test.rb +24 -0
- data/test/exercises/pattern_matching_test.rb +18 -0
- data/test/exercises/refinement_scope_test.rb +14 -0
- data/test/exercises/regexp_captures_test.rb +20 -0
- data/test/exercises/runtime_context_test.rb +59 -0
- data/test/exercises/shared_rows_test.rb +34 -0
- data/test/exercises/singleton_pattern_test.rb +16 -0
- data/test/exercises/time_and_date_test.rb +22 -0
- data/test/exercises/visibility_test.rb +22 -0
- metadata +471 -4
- data/Rakefile +0 -12
- data/sig/test_rkoans.rbs +0 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutModules
|
|
7
|
+
type answers = {
|
|
8
|
+
cant_instantiate_modules_one: (singleton(::NoMethodError) | :fill_me_in),
|
|
9
|
+
normal_methods_are_available_in_the_object_one: (::String | :fill_me_in),
|
|
10
|
+
module_methods_can_affect_instance_variables_in_the_object_one: (::String | :fill_me_in),
|
|
11
|
+
module_methods_can_affect_instance_variables_in_the_object_two: (::String | :fill_me_in),
|
|
12
|
+
classes_can_override_module_methods_one: (::Symbol | :fill_me_in)
|
|
13
|
+
}
|
|
14
|
+
def self.koans: -> answers
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class AboutModulesTest
|
|
19
|
+
def test_cant_instantiate_modules: -> void
|
|
20
|
+
def test_normal_methods_are_available_in_the_object: -> void
|
|
21
|
+
def test_module_methods_are_also_available_in_the_object: -> void
|
|
22
|
+
def test_module_methods_can_affect_instance_variables_in_the_object: -> void
|
|
23
|
+
def test_classes_can_override_module_methods: -> void
|
|
24
|
+
def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module AboutModulesTest::Nameable
|
|
28
|
+
def set_name: (::String new_name) -> ::String
|
|
29
|
+
def here: () -> ::Symbol
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class AboutModulesTest::Dog
|
|
33
|
+
include ::AboutModulesTest::Nameable
|
|
34
|
+
attr_reader name: ::String?
|
|
35
|
+
def initialize: () -> void
|
|
36
|
+
def bark: () -> ::String
|
|
37
|
+
def here: () -> ::Symbol
|
|
38
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutNil
|
|
7
|
+
type answers = {
|
|
8
|
+
nil_object: (bool | :fill_me_in),
|
|
9
|
+
missing_method_error: (singleton(NoMethodError) | :fill_me_in),
|
|
10
|
+
message_fragment: (String | :fill_me_in),
|
|
11
|
+
nil_predicate: (bool | :fill_me_in),
|
|
12
|
+
string_value: (String | :fill_me_in),
|
|
13
|
+
inspected_value: (String | :fill_me_in)
|
|
14
|
+
}
|
|
15
|
+
def self.koans: -> answers
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class AboutNilTest
|
|
20
|
+
def test_nil_is_an_object: -> void
|
|
21
|
+
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil: -> void
|
|
22
|
+
def test_nil_has_a_few_methods_defined_on_it: -> void
|
|
23
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutObjects
|
|
7
|
+
type answers = {
|
|
8
|
+
integer_object: (bool | :fill_me_in),
|
|
9
|
+
float_object: (bool | :fill_me_in),
|
|
10
|
+
string_object: (bool | :fill_me_in),
|
|
11
|
+
nil_object: (bool | :fill_me_in),
|
|
12
|
+
class_object: (bool | :fill_me_in),
|
|
13
|
+
integer_string: (String | :fill_me_in),
|
|
14
|
+
nil_string: (String | :fill_me_in),
|
|
15
|
+
integer_inspect: (String | :fill_me_in),
|
|
16
|
+
nil_inspect: (String | :fill_me_in),
|
|
17
|
+
id_type: (singleton(Integer) | :fill_me_in),
|
|
18
|
+
distinct_ids: (bool | :fill_me_in),
|
|
19
|
+
zero_id: (Integer | :fill_me_in),
|
|
20
|
+
one_id: (Integer | :fill_me_in),
|
|
21
|
+
two_id: (Integer | :fill_me_in),
|
|
22
|
+
hundred_id: (Integer | :fill_me_in),
|
|
23
|
+
clone_unequal: (bool | :fill_me_in),
|
|
24
|
+
clone_distinct_id: (bool | :fill_me_in)
|
|
25
|
+
}
|
|
26
|
+
def self.koans: -> answers
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class AboutObjectsTest
|
|
31
|
+
def test_everything_is_an_object: -> void
|
|
32
|
+
def test_objects_can_be_converted_to_strings: -> void
|
|
33
|
+
def test_objects_can_be_inspected: -> void
|
|
34
|
+
def test_every_object_has_an_id: -> void
|
|
35
|
+
def test_every_object_has_different_id: -> void
|
|
36
|
+
def test_small_integers_have_fixed_ids: -> void
|
|
37
|
+
def test_clone_creates_a_different_object: -> void
|
|
38
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutOpenClasses
|
|
7
|
+
type answers = {
|
|
8
|
+
as_defined_dogs_do_bark_one: (::String | :fill_me_in),
|
|
9
|
+
after_reopening_dogs_can_both_wag_and_bark_one: (::String | :fill_me_in),
|
|
10
|
+
after_reopening_dogs_can_both_wag_and_bark_two: (::String | :fill_me_in),
|
|
11
|
+
even_existing_built_in_classes_can_be_reopened_one: (bool | :fill_me_in),
|
|
12
|
+
even_existing_built_in_classes_can_be_reopened_two: (bool | :fill_me_in)
|
|
13
|
+
}
|
|
14
|
+
def self.koans: -> answers
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class AboutOpenClassesTest
|
|
19
|
+
def test_as_defined_dogs_do_bark: -> void
|
|
20
|
+
def test_after_reopening_dogs_can_both_wag_and_bark: -> void
|
|
21
|
+
def test_even_existing_built_in_classes_can_be_reopened: -> void
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class AboutOpenClassesTest::Dog
|
|
25
|
+
def bark: () -> ::String
|
|
26
|
+
def wag: () -> ::String
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class Integer
|
|
30
|
+
def answer_to_life_universe_and_everything?: () -> bool
|
|
31
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutPatternMatching
|
|
7
|
+
type answers = {
|
|
8
|
+
pattern_may_not_match_one: (singleton(::NoMatchingPatternError) | :fill_me_in),
|
|
9
|
+
we_can_use_else_one: (::Symbol | :fill_me_in),
|
|
10
|
+
value_pattern_one: (::Symbol | :fill_me_in),
|
|
11
|
+
value_pattern_two: (::Symbol | :fill_me_in),
|
|
12
|
+
value_pattern_three: (::Symbol | :fill_me_in),
|
|
13
|
+
value_pattern_four: (::Symbol | :fill_me_in),
|
|
14
|
+
variable_pattern_with_binding_one: (::Integer | :fill_me_in),
|
|
15
|
+
variable_pattern_with_pin_one: (::Symbol | :fill_me_in),
|
|
16
|
+
pattern_with_dropping_one: (::Symbol | :fill_me_in),
|
|
17
|
+
pattern_with_dropping_two: (::Symbol | :fill_me_in),
|
|
18
|
+
alternative_pattern_one: (::Symbol | :fill_me_in),
|
|
19
|
+
alternative_pattern_two: (::Symbol | :fill_me_in),
|
|
20
|
+
alternative_pattern_three: (::Symbol | :fill_me_in),
|
|
21
|
+
alternative_pattern_four: (::Symbol | :fill_me_in),
|
|
22
|
+
as_pattern_one: (::String | :fill_me_in),
|
|
23
|
+
array_pattern_one: (::Array[::String] | :fill_me_in),
|
|
24
|
+
array_pattern_two: (::Symbol | :fill_me_in),
|
|
25
|
+
hash_pattern_one: (::Array[::Integer] | :fill_me_in),
|
|
26
|
+
hash_pattern_two: (::Array[::Integer] | :fill_me_in),
|
|
27
|
+
hash_pattern_with_sugar_one: (::Array[::Integer] | :fill_me_in),
|
|
28
|
+
hash_pattern_with_sugar_two: (::Array[::Integer] | :fill_me_in)
|
|
29
|
+
}
|
|
30
|
+
def self.koans: -> answers
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class AboutPatternMatchingTest
|
|
35
|
+
def test_pattern_may_not_match: -> void
|
|
36
|
+
def test_we_can_use_else: -> void
|
|
37
|
+
def value_pattern: (Integer | String variable) -> Symbol
|
|
38
|
+
def test_value_pattern: -> void
|
|
39
|
+
def variable_pattern_with_binding: (Integer variable) -> Integer
|
|
40
|
+
def test_variable_pattern_with_binding: -> void
|
|
41
|
+
def variable_pattern_with_pin: (Integer variable) -> (Integer | Symbol)
|
|
42
|
+
def test_variable_pattern_with_pin: -> void
|
|
43
|
+
def pattern_with_dropping: (Array[untyped] variable) -> Symbol
|
|
44
|
+
def test_pattern_with_dropping: -> void
|
|
45
|
+
def alternative_pattern: (Integer | bool | nil variable) -> Symbol
|
|
46
|
+
def test_alternative_pattern: -> void
|
|
47
|
+
def as_pattern: -> String
|
|
48
|
+
def test_as_pattern: -> void
|
|
49
|
+
def array_pattern: (Deconstructible deconstructible) -> (Array[String] | Symbol)
|
|
50
|
+
def test_array_pattern: -> void
|
|
51
|
+
def hash_pattern: (LetterAccountant deconstructible_as_hash) -> (Array[Integer] | Symbol)
|
|
52
|
+
def test_hash_pattern: -> void
|
|
53
|
+
def hash_pattern_with_sugar: (LetterAccountant deconstructible_as_hash) -> (Array[Integer] | Symbol)
|
|
54
|
+
def test_hash_pattern_with_sugar: -> void
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class AboutPatternMatchingTest::Deconstructible
|
|
58
|
+
def initialize: (::String str) -> void
|
|
59
|
+
def deconstruct: -> Array[String]?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class AboutPatternMatchingTest::LetterAccountant
|
|
63
|
+
def initialize: (::String str) -> void
|
|
64
|
+
def deconstruct_keys: (Array[Symbol] keys) -> Hash[Symbol, Integer]
|
|
65
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class AboutProxyObjectProject
|
|
3
|
+
class Proxy
|
|
4
|
+
@target: Object
|
|
5
|
+
@messages: Array[Symbol]
|
|
6
|
+
attr_reader messages: Array[Symbol]
|
|
7
|
+
def initialize: (Object target) -> void
|
|
8
|
+
def method_missing: (Symbol name, *untyped, **untyped) ?{ (*untyped) -> untyped } -> untyped
|
|
9
|
+
def called?: (Symbol name) -> bool
|
|
10
|
+
def number_of_times_called: (Symbol name) -> Integer
|
|
11
|
+
private
|
|
12
|
+
def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
class AboutProxyObjectProjectTest::Television
|
|
17
|
+
@channel: Integer?
|
|
18
|
+
@on: bool?
|
|
19
|
+
attr_accessor channel: Integer?
|
|
20
|
+
def power: -> bool
|
|
21
|
+
def on?: -> bool
|
|
22
|
+
def broadcast: [A] (String message, ?suffix: String) ?{ (String) -> A } -> (A | String)
|
|
23
|
+
private
|
|
24
|
+
def secret: -> Symbol
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class AboutProxyObjectProjectTest
|
|
28
|
+
def test_tv_methods_and_recorded_messages: -> void
|
|
29
|
+
def test_string_target_and_return_values: -> void
|
|
30
|
+
def test_keywords_and_blocks_reach_the_target: -> void
|
|
31
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutRegularExpressions
|
|
7
|
+
type answers = {
|
|
8
|
+
a_pattern_is_a_regular_expression_one: (singleton(::Regexp) | :fill_me_in),
|
|
9
|
+
a_regexp_can_search_a_string_for_matching_content_one: (::String | :fill_me_in),
|
|
10
|
+
a_failed_match_returns_nil_one: (nil | :fill_me_in),
|
|
11
|
+
question_mark_means_optional_one: (::String | :fill_me_in),
|
|
12
|
+
question_mark_means_optional_two: (::String | :fill_me_in),
|
|
13
|
+
plus_means_one_or_more_one: (::String | :fill_me_in),
|
|
14
|
+
asterisk_means_zero_or_more_one: (::String | :fill_me_in),
|
|
15
|
+
asterisk_means_zero_or_more_two: (::String | :fill_me_in),
|
|
16
|
+
asterisk_means_zero_or_more_three: (::String | :fill_me_in),
|
|
17
|
+
the_left_most_match_wins_one: (::String | :fill_me_in),
|
|
18
|
+
character_classes_give_options_for_a_character_one: (::Array[::String] | :fill_me_in),
|
|
19
|
+
slash_d_is_a_shortcut_for_a_digit_character_class_one: (::String | :fill_me_in),
|
|
20
|
+
slash_d_is_a_shortcut_for_a_digit_character_class_two: (::String | :fill_me_in),
|
|
21
|
+
character_classes_can_include_ranges_one: (::String | :fill_me_in),
|
|
22
|
+
slash_s_is_a_shortcut_for_a_whitespace_character_class_one: (::String | :fill_me_in),
|
|
23
|
+
slash_w_is_a_shortcut_for_a_word_character_class_one: (::String | :fill_me_in),
|
|
24
|
+
slash_w_is_a_shortcut_for_a_word_character_class_two: (::String | :fill_me_in),
|
|
25
|
+
period_is_a_shortcut_for_any_non_newline_character_one: (::String | :fill_me_in),
|
|
26
|
+
a_character_class_can_be_negated_one: (::String | :fill_me_in),
|
|
27
|
+
shortcut_character_classes_are_negated_with_capitals_one: (::String | :fill_me_in),
|
|
28
|
+
shortcut_character_classes_are_negated_with_capitals_two: (::String | :fill_me_in),
|
|
29
|
+
shortcut_character_classes_are_negated_with_capitals_three: (::String | :fill_me_in),
|
|
30
|
+
shortcut_character_classes_are_negated_with_capitals_four: (::String | :fill_me_in),
|
|
31
|
+
slash_a_anchors_to_the_start_of_the_string_one: (::String | :fill_me_in),
|
|
32
|
+
slash_a_anchors_to_the_start_of_the_string_two: (nil | :fill_me_in),
|
|
33
|
+
slash_z_anchors_to_the_end_of_the_string_one: (::String | :fill_me_in),
|
|
34
|
+
slash_z_anchors_to_the_end_of_the_string_two: (nil | :fill_me_in),
|
|
35
|
+
caret_anchors_to_the_start_of_lines_one: (::String | :fill_me_in),
|
|
36
|
+
dollar_sign_anchors_to_the_end_of_lines_one: (::String | :fill_me_in),
|
|
37
|
+
slash_b_anchors_to_a_word_boundary_one: (::String | :fill_me_in),
|
|
38
|
+
parentheses_group_contents_one: (::String | :fill_me_in),
|
|
39
|
+
parentheses_also_capture_matched_content_by_number_one: (::String | :fill_me_in),
|
|
40
|
+
parentheses_also_capture_matched_content_by_number_two: (::String | :fill_me_in),
|
|
41
|
+
variables_can_also_be_used_to_access_captures_one: (::String | :fill_me_in),
|
|
42
|
+
variables_can_also_be_used_to_access_captures_two: (::String | :fill_me_in),
|
|
43
|
+
variables_can_also_be_used_to_access_captures_three: (::String | :fill_me_in),
|
|
44
|
+
a_vertical_pipe_means_or_one: (::String | :fill_me_in),
|
|
45
|
+
a_vertical_pipe_means_or_two: (::String | :fill_me_in),
|
|
46
|
+
a_vertical_pipe_means_or_three: (nil | :fill_me_in),
|
|
47
|
+
scan_is_like_find_all_one: (::Array[::String] | :fill_me_in),
|
|
48
|
+
sub_is_like_find_and_replace_one: (::String | :fill_me_in),
|
|
49
|
+
gsub_is_like_find_and_replace_all_one: (::String | :fill_me_in)
|
|
50
|
+
}
|
|
51
|
+
def self.koans: -> answers
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class AboutRegularExpressionsTest
|
|
56
|
+
def test_a_pattern_is_a_regular_expression: -> void
|
|
57
|
+
def test_a_regexp_can_search_a_string_for_matching_content: -> void
|
|
58
|
+
def test_a_failed_match_returns_nil: -> void
|
|
59
|
+
def test_question_mark_means_optional: -> void
|
|
60
|
+
def test_plus_means_one_or_more: -> void
|
|
61
|
+
def test_asterisk_means_zero_or_more: -> void
|
|
62
|
+
def test_the_left_most_match_wins: -> void
|
|
63
|
+
def test_character_classes_give_options_for_a_character: -> void
|
|
64
|
+
def test_slash_d_is_a_shortcut_for_a_digit_character_class: -> void
|
|
65
|
+
def test_character_classes_can_include_ranges: -> void
|
|
66
|
+
def test_slash_s_is_a_shortcut_for_a_whitespace_character_class: -> void
|
|
67
|
+
def test_slash_w_is_a_shortcut_for_a_word_character_class: -> void
|
|
68
|
+
def test_period_is_a_shortcut_for_any_non_newline_character: -> void
|
|
69
|
+
def test_a_character_class_can_be_negated: -> void
|
|
70
|
+
def test_shortcut_character_classes_are_negated_with_capitals: -> void
|
|
71
|
+
def test_slash_a_anchors_to_the_start_of_the_string: -> void
|
|
72
|
+
def test_slash_z_anchors_to_the_end_of_the_string: -> void
|
|
73
|
+
def test_caret_anchors_to_the_start_of_lines: -> void
|
|
74
|
+
def test_dollar_sign_anchors_to_the_end_of_lines: -> void
|
|
75
|
+
def test_slash_b_anchors_to_a_word_boundary: -> void
|
|
76
|
+
def test_parentheses_group_contents: -> void
|
|
77
|
+
def test_parentheses_also_capture_matched_content_by_number: -> void
|
|
78
|
+
def test_variables_can_also_be_used_to_access_captures: -> void
|
|
79
|
+
def test_a_vertical_pipe_means_or: -> void
|
|
80
|
+
def test_scan_is_like_find_all: -> void
|
|
81
|
+
def test_sub_is_like_find_and_replace: -> void
|
|
82
|
+
def test_gsub_is_like_find_and_replace_all: -> void
|
|
83
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class AboutSandwichCode
|
|
3
|
+
def self.count_lines: (String path) -> Integer
|
|
4
|
+
def self.find_line: (String path) -> String?
|
|
5
|
+
def self.file_sandwich: [A] (String path) { (File) -> A } -> A
|
|
6
|
+
def self.count_lines2: (String path) -> Integer
|
|
7
|
+
def self.find_line2: (String path) -> String?
|
|
8
|
+
def self.count_lines3: (String path) -> Integer
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class AboutSandwichCodeTest
|
|
13
|
+
def test_file_sandwich_closes_on_early_exit: -> void
|
|
14
|
+
def test_counting_and_finding_lines: -> void
|
|
15
|
+
def test_empty_and_unterminated_files: -> void
|
|
16
|
+
def test_file_sandwich_closes_on_success_and_exception: -> void
|
|
17
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutScope
|
|
7
|
+
type answers = {
|
|
8
|
+
dog_is_not_available_in_the_current_scope_one: (singleton(::NameError) | :fill_me_in),
|
|
9
|
+
you_can_reference_nested_classes_using_the_scope_operator_one: (::Symbol | :fill_me_in),
|
|
10
|
+
you_can_reference_nested_classes_using_the_scope_operator_two: (::Symbol | :fill_me_in),
|
|
11
|
+
you_can_reference_nested_classes_using_the_scope_operator_three: (bool | :fill_me_in),
|
|
12
|
+
you_can_reference_nested_classes_using_the_scope_operator_four: (bool | :fill_me_in),
|
|
13
|
+
bare_bones_class_names_assume_the_current_scope_one: (bool | :fill_me_in),
|
|
14
|
+
nested_string_is_not_the_same_as_the_system_string_one: (bool | :fill_me_in),
|
|
15
|
+
use_the_prefix_scope_operator_to_force_the_global_scope_one: (bool | :fill_me_in),
|
|
16
|
+
constants_are_defined_with_an_initial_uppercase_letter_one: (::Float | :fill_me_in),
|
|
17
|
+
class_names_are_just_constants_one: (bool | :fill_me_in),
|
|
18
|
+
class_names_are_just_constants_two: (bool | :fill_me_in),
|
|
19
|
+
constants_can_be_looked_up_explicitly_one: (bool | :fill_me_in),
|
|
20
|
+
constants_can_be_looked_up_explicitly_two: (bool | :fill_me_in),
|
|
21
|
+
you_can_get_a_list_of_constants_for_any_class_or_module_one: (::Array[::Symbol] | :fill_me_in),
|
|
22
|
+
you_can_get_a_list_of_constants_for_any_class_or_module_two: (bool | :fill_me_in)
|
|
23
|
+
}
|
|
24
|
+
def self.koans: -> answers
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class AboutScopeTest
|
|
29
|
+
def test_dog_is_not_available_in_the_current_scope: -> void
|
|
30
|
+
def test_you_can_reference_nested_classes_using_the_scope_operator: -> void
|
|
31
|
+
def test_bare_bones_class_names_assume_the_current_scope: -> void
|
|
32
|
+
def test_nested_string_is_not_the_same_as_the_system_string: -> void
|
|
33
|
+
def test_use_the_prefix_scope_operator_to_force_the_global_scope: -> void
|
|
34
|
+
def test_constants_are_defined_with_an_initial_uppercase_letter: -> void
|
|
35
|
+
def test_class_names_are_just_constants: -> void
|
|
36
|
+
def test_constants_can_be_looked_up_explicitly: -> void
|
|
37
|
+
def test_you_can_get_a_list_of_constants_for_any_class_or_module: -> void
|
|
38
|
+
def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module AboutScopeTest::Jims
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class AboutScopeTest::Jims::Dog
|
|
46
|
+
def identify: () -> ::Symbol
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
module AboutScopeTest::Joes
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class AboutScopeTest::Joes::Dog
|
|
54
|
+
def identify: () -> ::Symbol
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class AboutScopeTest::String
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class AboutScoringProject
|
|
3
|
+
def self.score: (Array[Integer] dice) -> Integer
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class AboutScoringProjectTest
|
|
8
|
+
def test_score_of_an_empty_list_is_zero: -> void
|
|
9
|
+
def test_score_of_a_single_roll_of_5_is_50: -> void
|
|
10
|
+
def test_score_of_a_single_roll_of_1_is_100: -> void
|
|
11
|
+
def test_score_of_multiple_1s_and_5s_is_the_sum_of_individual_scores: -> void
|
|
12
|
+
def test_score_of_single_2s_3s_4s_and_6s_are_zero: -> void
|
|
13
|
+
def test_score_of_a_triple_1_is_1000: -> void
|
|
14
|
+
def test_score_of_other_triples_is_100x: -> void
|
|
15
|
+
def test_score_of_mixed_is_sum: -> void
|
|
16
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutStrings
|
|
7
|
+
type answers = {
|
|
8
|
+
double_quoted_string: bool?,
|
|
9
|
+
single_quoted_string: bool?,
|
|
10
|
+
quoted_speech: String?,
|
|
11
|
+
apostrophe: String?,
|
|
12
|
+
escaped_quotes_equal: bool?,
|
|
13
|
+
flexible_percent_equal: bool?,
|
|
14
|
+
flexible_braces_equal: bool?,
|
|
15
|
+
multiline_length: Integer?,
|
|
16
|
+
multiline_lines: Integer?,
|
|
17
|
+
multiline_first_character: String?,
|
|
18
|
+
heredoc_length: Integer?,
|
|
19
|
+
heredoc_lines: Integer?,
|
|
20
|
+
heredoc_first_character: String?,
|
|
21
|
+
concatenated: String?,
|
|
22
|
+
plus_original: String?,
|
|
23
|
+
plus_other: String?,
|
|
24
|
+
plus_equals_result: String?,
|
|
25
|
+
plus_equals_original: String?,
|
|
26
|
+
append_result: String?,
|
|
27
|
+
append_other: String?,
|
|
28
|
+
appended_original: String?,
|
|
29
|
+
double_escape_length: Integer?,
|
|
30
|
+
single_escape_length: Integer?,
|
|
31
|
+
quote_escape_length: Integer?,
|
|
32
|
+
quote_escape_text: String?,
|
|
33
|
+
interpolated: String?,
|
|
34
|
+
not_interpolated: String?,
|
|
35
|
+
math_interpolation: String?,
|
|
36
|
+
substring_slice: String?,
|
|
37
|
+
substring_range: String?,
|
|
38
|
+
single_character: String?,
|
|
39
|
+
character_literal: String?,
|
|
40
|
+
character_equals_integer: bool?,
|
|
41
|
+
split_words: Array[String]?,
|
|
42
|
+
pattern_words: Array[String]?,
|
|
43
|
+
joined_words: String?,
|
|
44
|
+
equal_strings: bool?,
|
|
45
|
+
same_object: bool?
|
|
46
|
+
}
|
|
47
|
+
def self.koans: -> answers
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class AboutStringsQuotingTest
|
|
52
|
+
def test_double_quoted_strings_are_strings: -> void
|
|
53
|
+
def test_single_quoted_strings_are_also_strings: -> void
|
|
54
|
+
def test_use_single_quotes_to_create_string_with_double_quotes: -> void
|
|
55
|
+
def test_use_double_quotes_to_create_strings_with_single_quotes: -> void
|
|
56
|
+
def test_use_backslash_for_those_hard_cases: -> void
|
|
57
|
+
def test_use_flexible_quoting_to_handle_really_hard_cases: -> void
|
|
58
|
+
def test_flexible_quotes_can_handle_multiple_lines: -> void
|
|
59
|
+
def test_here_documents_can_also_handle_multiple_lines: -> void
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class AboutStringsMutationTest
|
|
63
|
+
def test_plus_will_concatenate_two_strings: -> void
|
|
64
|
+
def test_plus_concatenation_will_leave_the_original_strings_unmodified: -> void
|
|
65
|
+
def test_plus_equals_will_concatenate_to_the_end_of_a_string: -> void
|
|
66
|
+
def test_plus_equals_also_will_leave_the_original_string_unmodified: -> void
|
|
67
|
+
def test_the_shovel_operator_will_also_append_content_to_a_string: -> void
|
|
68
|
+
def test_the_shovel_operator_modifies_the_original_string: -> void
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class AboutStringsValuesTest
|
|
72
|
+
def test_double_quoted_string_interpret_escape_characters: -> void
|
|
73
|
+
def test_single_quoted_string_do_not_interpret_escape_characters: -> void
|
|
74
|
+
def test_single_quotes_sometimes_interpret_escape_characters: -> void
|
|
75
|
+
def test_double_quoted_strings_interpolate_variables: -> void
|
|
76
|
+
def test_single_quoted_strings_do_not_interpolate: -> void
|
|
77
|
+
def test_any_ruby_expression_may_be_interpolated: -> void
|
|
78
|
+
def test_you_can_get_a_substring_from_a_string: -> void
|
|
79
|
+
def test_you_can_get_a_single_character_from_a_string: -> void
|
|
80
|
+
def test_in_modern_ruby_single_characters_are_represented_by_strings: -> void
|
|
81
|
+
def test_strings_can_be_split: -> void
|
|
82
|
+
def test_strings_can_be_split_with_different_patterns: -> void
|
|
83
|
+
def test_strings_can_be_joined: -> void
|
|
84
|
+
def test_strings_are_unique_objects: -> void
|
|
85
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutSymbols
|
|
7
|
+
type answers = {
|
|
8
|
+
symbol_type: (bool | :fill_me_in),
|
|
9
|
+
same_value: (bool | :fill_me_in),
|
|
10
|
+
different_value: (bool | :fill_me_in),
|
|
11
|
+
identical_value: (bool | :fill_me_in),
|
|
12
|
+
same_object: (bool | :fill_me_in),
|
|
13
|
+
method_name_registered: (bool | :fill_me_in),
|
|
14
|
+
constant_name: (String | :fill_me_in),
|
|
15
|
+
constant_registered: (bool | :fill_me_in),
|
|
16
|
+
from_string: Symbol,
|
|
17
|
+
with_spaces: Symbol,
|
|
18
|
+
with_interpolation: Symbol,
|
|
19
|
+
interpolated_text: (String | :fill_me_in),
|
|
20
|
+
string_type: (bool | :fill_me_in),
|
|
21
|
+
equals_string: (bool | :fill_me_in),
|
|
22
|
+
each_char: (bool | :fill_me_in),
|
|
23
|
+
reverse: (bool | :fill_me_in),
|
|
24
|
+
concatenation_error: (singleton(NoMethodError) | :fill_me_in),
|
|
25
|
+
dynamically_created: Symbol
|
|
26
|
+
}
|
|
27
|
+
def self.koans: -> answers
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class AboutSymbolsTest
|
|
32
|
+
RUBY_CONSTANT: String
|
|
33
|
+
def test_symbols_are_symbols: -> void
|
|
34
|
+
def test_symbols_can_be_compared: -> void
|
|
35
|
+
def test_identical_symbols_are_a_single_internal_object: -> void
|
|
36
|
+
def test_method_names_become_symbols: -> void
|
|
37
|
+
def test_constants_become_symbols: -> void
|
|
38
|
+
def test_symbols_can_be_made_from_strings: -> void
|
|
39
|
+
def test_symbols_with_spaces_can_be_built: -> void
|
|
40
|
+
def test_symbols_with_interpolation_can_be_built: -> void
|
|
41
|
+
def test_to_s_is_called_on_interpolated_symbols: -> void
|
|
42
|
+
def test_symbols_are_not_strings: -> void
|
|
43
|
+
def test_symbols_do_not_have_string_methods: -> void
|
|
44
|
+
def test_symbols_cannot_be_concatenated: -> void
|
|
45
|
+
def test_symbols_can_be_dynamically_created: -> void
|
|
46
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
|
|
5
|
+
module Exercises
|
|
6
|
+
class AboutToStr
|
|
7
|
+
type answers = {
|
|
8
|
+
to_s_returns_a_string_representation_one: (::String | :fill_me_in),
|
|
9
|
+
normally_objects_cannot_be_used_where_strings_are_expected_one: (singleton(::TypeError) | :fill_me_in),
|
|
10
|
+
to_str_also_returns_a_string_representation_one: (::String | :fill_me_in),
|
|
11
|
+
to_str_allows_objects_to_be_treated_as_strings_one: (bool | :fill_me_in),
|
|
12
|
+
user_defined_code_can_check_for_to_str_one: (bool | :fill_me_in),
|
|
13
|
+
user_defined_code_can_check_for_to_str_two: (bool | :fill_me_in)
|
|
14
|
+
}
|
|
15
|
+
def self.koans: -> answers
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class AboutToStrTest
|
|
20
|
+
def test_to_s_returns_a_string_representation: -> void
|
|
21
|
+
def test_normally_objects_cannot_be_used_where_strings_are_expected: -> void
|
|
22
|
+
def test_to_str_also_returns_a_string_representation: -> void
|
|
23
|
+
def test_to_str_allows_objects_to_be_treated_as_strings: -> void
|
|
24
|
+
def acts_like_a_string?: (Object string) -> bool
|
|
25
|
+
def test_user_defined_code_can_check_for_to_str: -> void
|
|
26
|
+
def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class AboutToStrTest::CanNotBeTreatedAsString
|
|
30
|
+
def to_s: () -> ::String
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class AboutToStrTest::CanBeTreatedAsString
|
|
34
|
+
def to_s: () -> ::String
|
|
35
|
+
def to_str: () -> untyped
|
|
36
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class AboutTriangleProject
|
|
3
|
+
def self.triangle: (Numeric a, Numeric b, Numeric c) -> Symbol
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class AboutTriangleProjectTest
|
|
8
|
+
def test_equilateral_triangles_have_equal_sides: -> void
|
|
9
|
+
def test_isosceles_triangles_have_exactly_two_sides_equal: -> void
|
|
10
|
+
def test_scalene_triangles_have_no_equal_sides: -> void
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class AboutTriangleProjectTwo
|
|
3
|
+
class TriangleError < StandardError
|
|
4
|
+
end
|
|
5
|
+
def self.triangle: (Numeric a, Numeric b, Numeric c) -> Symbol
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class AboutTriangleProjectTwoTest
|
|
10
|
+
def test_illegal_triangles_throw_exceptions: -> void
|
|
11
|
+
def test_valid_triangles_keep_their_classification: -> void
|
|
12
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SPDX-License-Identifier: CC-BY-NC-SA-3.0
|
|
2
|
+
# Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
|
|
3
|
+
# See THIRD_PARTY_NOTICES.md for attribution and license terms.
|
|
4
|
+
module Exercises
|
|
5
|
+
class AboutTrueAndFalse
|
|
6
|
+
type answers = {
|
|
7
|
+
true_value: (:true_stuff | :false_stuff)?,
|
|
8
|
+
false_value: (:true_stuff | :false_stuff)?,
|
|
9
|
+
nil_value: (:true_stuff | :false_stuff)?,
|
|
10
|
+
one: (:true_stuff | :false_stuff)?,
|
|
11
|
+
zero: (:true_stuff | :false_stuff)?,
|
|
12
|
+
empty_array: (:true_stuff | :false_stuff)?,
|
|
13
|
+
empty_hash: (:true_stuff | :false_stuff)?,
|
|
14
|
+
string: (:true_stuff | :false_stuff)?,
|
|
15
|
+
empty_string: (:true_stuff | :false_stuff)?
|
|
16
|
+
}
|
|
17
|
+
def self.koans: -> answers
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class AboutTrueAndFalseTest
|
|
22
|
+
def truth_value: (Object condition) -> (:true_stuff | :false_stuff)
|
|
23
|
+
def test_true_is_treated_as_true: -> void
|
|
24
|
+
def test_false_is_treated_as_false: -> void
|
|
25
|
+
def test_nil_is_treated_as_false_too: -> void
|
|
26
|
+
def test_everything_else_is_treated_as_true: -> void
|
|
27
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class BlocksAndMethods
|
|
3
|
+
def self.koans: -> { sequence: Array[Integer]? }
|
|
4
|
+
def self.apply: [T] (Integer value) { (Integer) -> T } -> T
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class BlocksAndMethodsTest
|
|
9
|
+
def test_block_koan: -> void
|
|
10
|
+
def test_apply_block: -> void
|
|
11
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Exercises
|
|
2
|
+
class ClassState
|
|
3
|
+
class Parent
|
|
4
|
+
def self.reset: -> Integer
|
|
5
|
+
def self.count: -> Integer
|
|
6
|
+
def self.increment: -> Integer
|
|
7
|
+
def self.label: -> String
|
|
8
|
+
end
|
|
9
|
+
class Child < Parent
|
|
10
|
+
def self.label: -> String
|
|
11
|
+
end
|
|
12
|
+
def self.singleton_owner: -> Class
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class ClassStateTest
|
|
17
|
+
def test_independent_class_instance_state: -> void
|
|
18
|
+
def test_class_inheritance_and_singleton: -> void
|
|
19
|
+
end
|