Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imitate / replace things deeply (instead of shallow) #268

Merged
merged 37 commits into from
Jun 24, 2017

Commits on Jun 21, 2017

  1. Fix the repl by using useGlobal

    This was causing all our metaprogramming that checked types to break.
    See: nodejs/node#13827
    searls committed Jun 21, 2017
    Configuration menu
    Copy the full SHA
    c6c3ff0 View commit details
    Browse the repository at this point in the history

Commits on Jun 22, 2017

  1. Rework prop utilities to grab and pass descriptors

    This is necessary for avoiding cases where even accessing the property
    will set off a getter, or blow up in strict mode (e.g. accessing
    arguments or caller/callee on something). Instead, we'll look at the
    descriptor's `value` property, which is relatively "inert" by comparison
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    adea88c View commit details
    Browse the repository at this point in the history
  2. Avoid copying & then mutating by accepting a visit

    When copying props, you can adjust the value with a func arg
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    c451e72 View commit details
    Browse the repository at this point in the history
  3. Rough draft of this imitation func

    Does not work but figured like I may as well save my place
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    3f7c935 View commit details
    Browse the repository at this point in the history
  4. Change rules on copyProps

    Should overwrite fields, but only if they're both writable &
    configurable. If the target has a field that's somehow neither of these,
    then it's almost certainly some kind of built-in like
    Function.prototype.length
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    a86905a View commit details
    Browse the repository at this point in the history
  5. Reduce args on copyProps

    It no longer needs the original because it has the full property
    descriptor
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    37ca57c View commit details
    Browse the repository at this point in the history
  6. Get basic imitation working as desired

    This required using the most-valuey of types as base cases in the
    recursion, because it'd muck with the perceived value of things like
    Date and moreover would fake 30+ string methods for probably zero
    benefit and lots of confusion. (Only affects boxed instances of these
    prims)
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    590c50c View commit details
    Browse the repository at this point in the history
  7. Test error objects specially

    Surprisingly lodash isEqual fails on two errors but only if one is
    cloned. Meanwhile, assert module will pass deepEqual on two errors if
    the messages differ. Fantastic
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    8469b45 View commit details
    Browse the repository at this point in the history
  8. standard --fix

    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    b4f6eea View commit details
    Browse the repository at this point in the history
  9. Get more serious about improving naming.

    Push all the naming chains into the imitation object, since it's the
    only call site with sufficient context
    searls committed Jun 22, 2017
    Configuration menu
    Copy the full SHA
    11d8dfd View commit details
    Browse the repository at this point in the history

Commits on Jun 23, 2017

  1. Wire up new imitation center.

    This got the tests passing, but may save us the need for extending
    types options (thanks to just using prototype and not class syntax)
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    d83f661 View commit details
    Browse the repository at this point in the history
  2. standard --fix

    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    dd437a2 View commit details
    Browse the repository at this point in the history
  3. Get this working under phantom (Map, Symbol)

    Add a Map polyfill to get things working under older browsers, also
    refer to Symbol in such a way that it's backwards compatible
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    14d62b1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b5e952c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1a48ede View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    519cd58 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0f66b8e View commit details
    Browse the repository at this point in the history
  8. Add a test suggesting instanceof checks work

    I did this in an example project to be sure it was a native (not
    transpiled) class being "extended" by td.js. This is the case that was
    failing during the 2.x series and necessitated the extendCo… option
    for 3.x
    
    This test passes, so we can delete that option next
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    074d307 View commit details
    Browse the repository at this point in the history
  9. Remove extendWhenReplacingConstructors option

    The improvements in the new imitate function sidestep the babel class
    extension issue that prompted the introduction of this option. All fakes
    will pass instanceof checks as a matter of course now.
    
    Of course, this means that a major bump will be necessary, since that
    config option will have been removed and anyone setting it will blow up…
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    f61995b View commit details
    Browse the repository at this point in the history
  10. Spare ourselves the major bump by deprecating prop

    I feel like I earn 3 points for lazily giving people a
    let-me-github-that-for-you URL and lose 2 points for lazily pasting in
    an error message
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    55d58fe View commit details
    Browse the repository at this point in the history
  11. standard --fix

    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    7ef2b5d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    5f15650 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    3fd25b5 View commit details
    Browse the repository at this point in the history
  14. Move unit tests under test/unit

    Doing this in prep of adding a second teenytest suite under test/safe
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    d3b09fb View commit details
    Browse the repository at this point in the history
  15. Move imitate fun

    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    fbb1fbf View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    1b2c936 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    9aded7b View commit details
    Browse the repository at this point in the history
  18. Start detangling imitiate as prefactoring

    Also we stopped printing '#' as shorthand for 'prototype'. It was
    complicating the code, and on further reflection it makes the messages
    harder for anyone who's not "in the know" with respect to '#' being a
    symbol for "instance method" (as opposed to '.' for plain function)
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    dc2a4d5 View commit details
    Browse the repository at this point in the history
  19. Pair with @andrewvida to refactor imitate()

    This refactor started by teasing the tangled function into its separate
    roles, then pushing the behavior down into 3 new units.
    
    The unit test for the refactored thing is particularly interesting,
    because it required use of argument captors to trigger the downstream
    behavior. This was necessary because the method was recursive, and we
    needed to invoke the subject twice, once indirectly. It's hard to find
    good examples of argument captors, so here you go.
    searls committed Jun 23, 2017
    Configuration menu
    Copy the full SHA
    c0e8b21 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2017

  1. Drive out a fresh impl of initialize-names

    Turns out most of the logic was pretty dumb and it's new behavior so I
    just axed most of it
    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    37ccdc8 View commit details
    Browse the repository at this point in the history
  2. Test the thing that creates the root fakes

    These are just the node-level replacement, their properties (or for
    arrays, elements) will be replaced by overwriteChildren
    
    Simplied somewhat, when I learned through the test that underscore's
    clone works well enough for primitives (one would trust, efficiently
    enough)
    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    f3145e5 View commit details
    Browse the repository at this point in the history
  3. Pushed down 4 things in overwrite children

    Lots of complexity got swept under this rug, really causing some pain at
    the periphery. Since it's a leaf node, will I ever look at it again?
    Probably not.
    
    Some notes:
      * ../../../.. is outrageous. I should figure out how to go about
      getting the unit tests colocated with the source soon.
      * 5 arguments for chain-prototype.js? Seriously? That can't be
      necessary
      * This overwrite-children/index test is really the kitchen sink of
      edge cases for delegator objects. It has replaced deps, it has one-off
      test double functions passed as arguments, it has argument captors for
      getting callbacks under isolated tests, it has verifications that
      certain dependencies were absolutely not called. It's got it all!
    
      All of these are smells that this unit is weird/awkward. It's possible that
      things got complex because the code originated while  trying to tidy up the
      behavior originally in the context of a big method with lots of closure-scoped
      variables available. That explains the 5 arg function (once extracted
      and closure-scope is lost), as well as the visitor pattern sort of
      callbacks to keep the recursion step out-of-sight of the extracted
      unit.
    
      Unsure how I'd rework it at this point to breathe like a normal
      function, though. That's why I should have test-drove this from
      scratch instead of test-aftering and pushing down all these things!
      Whoops!
    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    a353f1d View commit details
    Browse the repository at this point in the history
  4. standard fix

    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    92f1354 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    754fd79 View commit details
    Browse the repository at this point in the history
  6. standard --fix

    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    9d7fb8d View commit details
    Browse the repository at this point in the history
  7. Clear out needless indirection

    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    76093c1 View commit details
    Browse the repository at this point in the history
  8. Test the primitive-checker

    searls committed Jun 24, 2017
    Configuration menu
    Copy the full SHA
    2fce02b View commit details
    Browse the repository at this point in the history