1. 25 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Reorganise and test std::time · 7f0cb46b
      Yorick Peterse authored
      std::time is now broken up into two modules:
      1. std::time, which provides time related types.
      2. std::time::duration, which provides the Duration type.
      This separation allows for the use of module methods to construct a
      Duration using different time units, instead of using methods defined on
      Duration itself. This means that instead of this:
          import std::time::Duration
      You now write this:
          import std::time::duration
      == Renaming MonotonicTime to Instant
      MonotonicTime has been renamed to "Instant", which is a bit shorter and
      much easier to type. A new method has been added as well: "elapsed".
      This method can be used to measure the time that has elapsed since the
      Instant was created.
      == Adding and subtracting SystemTime and Instant
      The methods + and - for SystemTime and Instant no longer accept a
      ToFloat, instead they require a Duration. Accepting a ToFloat would
      allow you to add a SystemTime to another SystemTime, or add an Instant
      to an Instant. Neither make sense, so instead we now require the use of
      a Duration. This means that instead of this:
          import std::time
          time.now + 5
      You now have to write this:
          import std::time
          import std::time::duration
          time.now + duration.from_seconds(5)
      == Tests
      Finally, both std::time and std::time::duration have tests. These tests
      uncovered a few bugs in the implementation of SystemTime, which have
      been resolved.
  2. 10 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Tests for std::process and remove receive_if · bf0d6d66
      Yorick Peterse authored
      This adds tests for `std::process`, and removes
      `std::process.receive_if`. The `receive_if` method has always been a bit
      of a weird method. It was originally meant to allow some form of pattern
      matching on messages, but this turned out to be less useful than hoped
      due to the return type still being `Dynamic`.
      The `timeout` argument was also not used properly, and solving this
      would not be easily doable.  This is because there was no single
      operation to apply the timeout to, instead the implementation of
      `receive_if` contained two `receive` calls, and some other logic.
      Handling all this would require us to keep track of the elapsed time
      ourselves, which is rather tricky should the process be stuck in a
      blocking receive.
      Instead of trying to come up with all kinds of crazy ideas, I have opted
      to simply remove `receive_if` for the time being. This makes some test
      runner code a bit more fragile (in theory), but I doubt this will pose
      any real problems any time soon.