Marco Ricci commited on 2025-01-25 00:16:59
              Zeige 1 geänderte Dateien mit 29 Einfügungen und 19 Löschungen.
            
Apart from higher resistance to typos, this also communicates the intent of the strategy more clearly.
| ... | ... | 
                      @@ -16,18 +16,36 @@ import tests  | 
                  
| 16 | 16 | 
                        from derivepassphrase import _types  | 
                    
| 17 | 17 | 
                         | 
                    
| 18 | 18 | 
                         | 
                    
| 19 | 
                        -@tests.hypothesis_settings_coverage_compatible  | 
                    |
| 20 | 
                        -@hypothesis.given(  | 
                    |
| 21 | 
                        - value=strategies.one_of(  | 
                    |
| 22 | 
                        - strategies.recursive(  | 
                    |
| 19 | 
                        +@strategies.composite  | 
                    |
| 20 | 
                        +def js_atoms_strategy(  | 
                    |
| 21 | 
                        + draw: strategies.DrawFn,  | 
                    |
| 22 | 
                        +) -> int | float | str | bytes | bool | None:  | 
                    |
| 23 | 
                        + """Yield a JS atom."""  | 
                    |
| 24 | 
                        + return draw(  | 
                    |
| 23 | 25 | 
                        strategies.one_of(  | 
                    
| 24 | 
                        - strategies.none(),  | 
                    |
| 25 | 
                        - strategies.booleans(),  | 
                    |
| 26 | 26 | 
                        strategies.integers(),  | 
                    
| 27 | 27 | 
                        strategies.floats(allow_nan=False, allow_infinity=False),  | 
                    
| 28 | 28 | 
                        strategies.text(max_size=100),  | 
                    
| 29 | 29 | 
                        strategies.binary(max_size=100),  | 
                    
| 30 | 
                        + strategies.booleans(),  | 
                    |
| 31 | 
                        + strategies.none(),  | 
                    |
| 30 | 32 | 
                        ),  | 
                    
| 33 | 
                        + )  | 
                    |
| 34 | 
                        +  | 
                    |
| 35 | 
                        +  | 
                    |
| 36 | 
                        +@strategies.composite  | 
                    |
| 37 | 
                        +def js_nested_strategy(draw: strategies.DrawFn) -> Any:  | 
                    |
| 38 | 
                        + """Yield an arbitrary and perhaps nested JS value."""  | 
                    |
| 39 | 
                        + return draw(  | 
                    |
| 40 | 
                        + strategies.one_of(  | 
                    |
| 41 | 
                        + js_atoms_strategy(),  | 
                    |
| 42 | 
                        + strategies.builds(tuple),  | 
                    |
| 43 | 
                        + strategies.builds(list),  | 
                    |
| 44 | 
                        + strategies.builds(dict),  | 
                    |
| 45 | 
                        + strategies.builds(set),  | 
                    |
| 46 | 
                        + strategies.builds(frozenset),  | 
                    |
| 47 | 
                        + strategies.recursive(  | 
                    |
| 48 | 
                        + js_atoms_strategy(),  | 
                    |
| 31 | 49 | 
                        lambda s: strategies.one_of(  | 
                    
| 32 | 50 | 
                        strategies.frozensets(s, max_size=100),  | 
                    
| 33 | 51 | 
                        strategies.builds(  | 
                    
| ... | ... | 
                      @@ -37,27 +55,19 @@ from derivepassphrase import _types  | 
                  
| 37 | 55 | 
                        max_leaves=8,  | 
                    
| 38 | 56 | 
                        ),  | 
                    
| 39 | 57 | 
                        strategies.recursive(  | 
                    
| 40 | 
                        - strategies.one_of(  | 
                    |
| 41 | 
                        - strategies.none(),  | 
                    |
| 42 | 
                        - strategies.booleans(),  | 
                    |
| 43 | 
                        - strategies.integers(),  | 
                    |
| 44 | 
                        - strategies.floats(allow_nan=False, allow_infinity=False),  | 
                    |
| 45 | 
                        - strategies.text(max_size=100),  | 
                    |
| 46 | 
                        - strategies.binary(max_size=100),  | 
                    |
| 47 | 
                        - ),  | 
                    |
| 58 | 
                        + js_atoms_strategy(),  | 
                    |
| 48 | 59 | 
                        lambda s: strategies.one_of(  | 
                    
| 49 | 60 | 
                        strategies.lists(s, max_size=100),  | 
                    
| 50 | 61 | 
                        strategies.dictionaries(strategies.text(max_size=100), s),  | 
                    
| 51 | 62 | 
                        ),  | 
                    
| 52 | 63 | 
                        max_leaves=25,  | 
                    
| 53 | 64 | 
                        ),  | 
                    
| 54 | 
                        - strategies.builds(tuple),  | 
                    |
| 55 | 
                        - strategies.builds(list),  | 
                    |
| 56 | 
                        - strategies.builds(dict),  | 
                    |
| 57 | 
                        - strategies.builds(set),  | 
                    |
| 58 | 
                        - strategies.builds(frozenset),  | 
                    |
| 59 | 65 | 
                        ),  | 
                    
| 60 | 66 | 
                        )  | 
                    
| 67 | 
                        +  | 
                    |
| 68 | 
                        +  | 
                    |
| 69 | 
                        +@tests.hypothesis_settings_coverage_compatible  | 
                    |
| 70 | 
                        +@hypothesis.given(value=js_nested_strategy())  | 
                    |
| 61 | 71 | 
                         @hypothesis.example(float('nan'))
                       | 
                    
| 62 | 72 | 
                        def test_100_js_truthiness(value: Any) -> None:  | 
                    
| 63 | 73 | 
                        """Determine the truthiness of a value according to JavaScript.  | 
                    
| 64 | 74 |