Commit Graph

8 Commits

Author SHA1 Message Date
Kirill Elagin
40069d4b2b Allow not changing file handles to UTF-8
The old interface only allowed one to perform terminal detection on a
handle and change it to UTF-8 if it was not a terminal. Turns our, it
makes sense to sometimes leave the original encoding on a handle even if
it does not point to a terminal.

* Change the interface to separate these two use-cases.
* Extract main-wrappers to a new `Main` module.
2020-02-17 19:39:40 -05:00
Kirill Elagin
8a76bb2577 Add test for a binary terminal 2020-02-17 17:58:29 -05:00
Kirill Elagin
93bf56ea57 test: Use a pseudo-terminal for testing
Previously the code was using stdout for testing the terminal detection
functionality. However, there is no guarantee that the tests will always
be running with stdout attached to a terminal.

Create a fresh pseudo-terminal instead and use it instead of stdout.
2020-02-17 17:58:29 -05:00
Kirill Elagin
f6bc3fc0ca Add correctness tests
* Split out the actual encoding choice logic into a separate Internal
  module to make it possible to cover it with tests.
* Make this function a little more efficient compared to the previous
  purely pure function.
* Keep a completely pure function as a specficiation for ease of reading
  and for testing by comparing the actualy function to the pure one.

* Add tests that check that the pure function makes sense.
* Add tests that compare the output of the real function to the output
  of the pure function on some real handles.
* Add tests that check that functions that are supposed to actually
  modify the encoding of a handle actually do modify it.
2020-02-17 17:58:29 -05:00
Kirill Elagin
7b33f6743b Remove obsolete import 2020-02-16 21:08:41 -05:00
Kirill Elagin
2a63a74c0c fixup: Remove unused module 2020-02-15 23:41:24 -05:00
Kirill Elagin
15acfcf9c6 Add missing licensing information 2020-02-15 21:12:08 -05:00
Kirill Elagin
08407bbe4d First version 2020-02-15 19:15:52 -05:00