Skip to content

Instantly share code, notes, and snippets.

@BioPhoton
Last active March 21, 2020 12:35

Revisions

  1. BioPhoton revised this gist Mar 21, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -111,7 +111,6 @@ import {TestScheduler} from 'rxjs/internal/testing/TestScheduler';
    const testScheduler = new TestScheduler(observableMatcher);

    testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {

    const s1 = hot('-^-x------------------| ');
    const s1Subs = ' ^--------------------! ';
    const n1 = cold(' ------------------------|');
  2. BioPhoton revised this gist Mar 21, 2020. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -72,6 +72,13 @@ describe.only('`^`', () => {
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
    ## Guide lines
    ### 0 index usage
    The zero index exists only in hot observables and can be specified by using `^`.
    If not specified it exists implizitly at the beginning of an hot observable.
    ```typescript
    hot('----|') === hot(' ----|') === hot('^---|') === hot(' ^---|')
    hot('-^---|') === hot('-^---|') :D
    ```
    ### 0 index alignment
  3. BioPhoton revised this gist Mar 21, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -105,10 +105,10 @@ const testScheduler = new TestScheduler(observableMatcher);

    testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {

    const s1 = hot('-^-x------------------|');
    const s1Subs = ' ^--------------------!';
    const n1 = cold(' -------------------|');
    const n1Subs = [' --^------------------!'];
    const exp = ' --x------------------|';
    const s1 = hot('-^-x------------------| ');
    const s1Subs = ' ^--------------------! ';
    const n1 = cold(' ------------------------|');
    const n1Subs = [' --^------------------! '];
    const exp = ' --x------------------| ';
    })
    ```
  4. BioPhoton revised this gist Mar 21, 2020. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    Confusing:
    ## Confusing

    - `(` and `)` count as frame
    ```typescript
    describe('`(` and `)`', () => {
    @@ -70,9 +71,10 @@ describe.only('`^`', () => {
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
    **Guide lines**
    ## Guide lines
    ### 0 index alignment
    0 index alignment:
    ```typescript

    // Old style ==================
  5. BioPhoton revised this gist Mar 21, 2020. 1 changed file with 42 additions and 1 deletion.
    43 changes: 42 additions & 1 deletion acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -68,4 +68,45 @@ describe.only('`^`', () => {
    });
    ```
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
    **Guide lines**
    0 index alignment:
    ```typescript

    // Old style ==================
    import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';

    const s1 = hot('-^-x------------------|');
    const s1Subs = '^ !';
    const n1 = cold(' ------------------------|');
    const n1Subs = [' ^ !'];
    const exp = '--x------------------|';

    // New style ==================
    import {TestScheduler} from 'rxjs/internal/testing/TestScheduler';

    const testScheduler = new TestScheduler(observableMatcher);

    testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {
    const s1 = hot('-^-x------------------| ');
    const s1Subs = '^--------------------! ';
    const n1 = cold('------------------------|');
    const n1Subs = ['--^------------------! '];
    const exp = '--x------------------| ';

    // New style proper 0 index alignment ==================
    import {TestScheduler} from 'rxjs/internal/testing/TestScheduler';

    const testScheduler = new TestScheduler(observableMatcher);

    testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {

    const s1 = hot('-^-x------------------|');
    const s1Subs = ' ^--------------------!';
    const n1 = cold(' -------------------|');
    const n1Subs = [' --^------------------!'];
    const exp = ' --x------------------|';
    })
    ```
  6. BioPhoton revised this gist Mar 20, 2020. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -38,4 +38,34 @@ describe('`(` and `)`', () => {
    });
    ```
    - `^` only exists in hot observables
    ```typescript
    describe.only('`^`', () => {
    let testScheduler: TestScheduler;

    beforeEach(() => {
    testScheduler = new TestScheduler(observableMatcher);
    });
    it('should take one frame', () => {
    const a = cold('-1---|');
    const a1 = '-1---|';
    const aSubs = [
    '^----!'
    ];
    const ar = a.pipe(tap());
    expectObservable(ar).toBe(a1);
    expectSubscriptions(a.subscriptions).toBe(aSubs);
    });
    it('should exist only on hot observables and outputs ans subscriptions', () => {
    testScheduler.run(({hot, expectObservable}) => {
    const a = hot('^1----------|');
    const a1 = '^1----------|';
    const aSubs = '^-----------!';
    const ar = a.pipe(tap());
    expectObservable(ar).toBe(a1);
    expectSubscriptions(a.subscriptions).toBe(aSubs);
    });
    });
    });
    ```
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
  7. BioPhoton revised this gist Mar 20, 2020. 1 changed file with 26 additions and 18 deletions.
    44 changes: 26 additions & 18 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -8,26 +8,34 @@ describe('`(` and `)`', () => {
    testScheduler = new TestScheduler(observableMatcher);
    });

    it('should should take one frame for `(` and one framr for `)`', () => {
    testScheduler.run(({cold, hot, expectObservable}) => {
    const a = cold('---------------|');
    const a1 = '-()------------|';
    const b = cold('----1----------|');
    const b1 = '-()-(1)--------|';
    const b2 = '-()-(1)--()----|';
    const c = cold('----1----(23)--|');
    const c1 = '-()-(1)()(23)--|';
    const c2 = '-()-(1)()(23)--|';
    const c3 = '-()-(1)()(23)()|';
    expectObservable(a).toBe(a1);
    expectObservable(b).toBe(b1);
    expectObservable(b).toBe(b2);
    expectObservable(c).toBe(c1);
    expectObservable(c).toBe(c2);
    expectObservable(c).toBe(c3);

    describe.only('`(` and `)`', () => {
    let testScheduler: TestScheduler;

    beforeEach(() => {
    testScheduler = new TestScheduler(observableMatcher);
    });

    it('should take one frame for `(` and one frame for `)`', () => {
    testScheduler.run(({cold, hot, expectObservable}) => {
    const a = cold('---------------|');
    const a1 = '-()------------|';
    const b = cold('----1----------|');
    const b1 = '-()-(1)--------|';
    const b2 = '-()-(1)--()----|';
    const c = cold('----1----(23)--|');
    const c1 = '-()-(1)()(23)--|';
    const c2 = '-()-(1)()(23)--|';
    const c3 = '-()-(1)()(23)()|';
    expectObservable(a).toBe(a1);
    expectObservable(b).toBe(b1);
    expectObservable(b).toBe(b2);
    expectObservable(c).toBe(c1);
    expectObservable(c).toBe(c2);
    expectObservable(c).toBe(c3);
    });
    });
    });
    });
    ```
    - `^` only exists in hot observables
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
  8. BioPhoton revised this gist Mar 20, 2020. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,33 @@
    Confusing:
    - `(` and `)` count as frame
    ```typescript
    describe('`(` and `)`', () => {
    let testScheduler: TestScheduler;

    beforeEach(() => {
    testScheduler = new TestScheduler(observableMatcher);
    });

    it('should should take one frame for `(` and one framr for `)`', () => {
    testScheduler.run(({cold, hot, expectObservable}) => {
    const a = cold('---------------|');
    const a1 = '-()------------|';
    const b = cold('----1----------|');
    const b1 = '-()-(1)--------|';
    const b2 = '-()-(1)--()----|';
    const c = cold('----1----(23)--|');
    const c1 = '-()-(1)()(23)--|';
    const c2 = '-()-(1)()(23)--|';
    const c3 = '-()-(1)()(23)()|';
    expectObservable(a).toBe(a1);
    expectObservable(b).toBe(b1);
    expectObservable(b).toBe(b2);
    expectObservable(c).toBe(c1);
    expectObservable(c).toBe(c2);
    expectObservable(c).toBe(c3);
    });
    });
    });
    ```
    - `^` only exists in hot observables
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
  9. BioPhoton revised this gist Mar 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Confusing:
    - `(` and `)` count as frame
    - `^` only exists in hot observables
    - ' ' is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
    - ` ` is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
  10. BioPhoton revised this gist Mar 20, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    Confusing:
    - `(` and `)` count as frame
    - `^` only exists in hot observables
    - `^` only exists in hot observables
    - ' ' is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
  11. BioPhoton created this gist Mar 20, 2020.
    3 changes: 3 additions & 0 deletions acii-marbles.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Confusing:
    - `(` and `)` count as frame
    - `^` only exists in hot observables