Git Product home page Git Product logo

Comments (8)

tjaskula avatar tjaskula commented on June 8, 2024

@VaughnVernon Checked the test and it still fails and completes.hasFailed() is false

As I'm changing in .NET implementation how continuations are executed, I have exactly the same problem now. From what I see as .andThen(new Integer(-100), (value) -> 2 * value) is scheduled for execution immediately when we call completes.With(-100); it doesn't matter anymore, because the continuation was already run.

I'm lost what should be the correct behavior.

from xoom-common.

tjaskula avatar tjaskula commented on June 8, 2024

@VaughnVernon Checked the test and it still fails and completes.hasFailed() is false

As I'm changing in .NET implementation how continuations are executed, I have exactly the same problem now. From what I see as .andThen(new Integer(-100), (value) -> 2 * value) is scheduled for execution immediately when we call completes.With(-100); it doesn't matter anymore, because the continuation was already run.

I'm lost what should be the correct behavior.

Seems like it's not that. Everything starts to execute only when with(-100) is called. So it seems that it's not fixed yet

from xoom-common.

VaughnVernon avatar VaughnVernon commented on June 8, 2024

@tjaskula The execution must not start until with(outcome). The test is clean on local and Travis. There were bugs in your test so I had to change it. See the fixed test in BasicCompletesTest.

from xoom-common.

tjaskula avatar tjaskula commented on June 8, 2024

@VaughnVernon Ok, this is the new test

@Test
  public void testThatNonNullFailureOutcomeFails() {
    final Completes<Integer> completes = new BasicCompletes<>(new Scheduler());

    completes
            .andThen(new Integer(-100), (value) -> 2 * value)
            .andThen((x) -> andThenValue = x)
            .otherwise((x) -> failureValue = 1000);

    completes.with(-100);

    final Integer completed = completes.await();

    assertTrue(completes.hasFailed());
    assertEquals(new Integer(1000), completed);
    assertEquals(null, andThenValue);
    assertEquals(new Integer(1000), failureValue);
  }

My question is why assertEquals(new Integer(1000), completed); ? I thought that in that case the execution of 2 * value should not have happened and the 1000 not computed ?

It means that even if the failedOutcomeValue == passed in value it executes the current continuation but not the next one and if fails back to otherwise ?

from xoom-common.

VaughnVernon avatar VaughnVernon commented on June 8, 2024

@tjaskula The otherwise is executed because of the failure valve and it sets 1000.

from xoom-common.

tjaskula avatar tjaskula commented on June 8, 2024

Ok, so it executes the function and tries to execute the Otherwise branch with failedOutcome

from xoom-common.

VaughnVernon avatar VaughnVernon commented on June 8, 2024

Yes. It should be that any outcome in the pipeline that produces the failure value should execute the otherwise function. This includes before the first andThen.

from xoom-common.

tjaskula avatar tjaskula commented on June 8, 2024

Ok but the failure value must equal the outcome of previous execution or passed in value

from xoom-common.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.