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

A bug in base.compose()? #4

Closed
MiroHibler opened this issue Dec 7, 2013 · 1 comment
Closed

A bug in base.compose()? #4

MiroHibler opened this issue Dec 7, 2013 · 1 comment

Comments

@MiroHibler
Copy link

Hi Joshua,

Great work!

While building my application around it, I discovered a bug in base.compose() method.

I ran this test:

var assert = require('assert')
var base = require("../jot/jot/base.js");

var e = [
    {
        "module_name": "sequences.js",
        "type": "apply",
        "pos":0,
        "op": {
            "module_name": "objects.js",
            "type": "apply",
            "key": "element",
            "op": {
                "module_name": "objects.js",
                "type": "apply",
                "key": "attrs",
                "op": {
                    "module_name": "objects.js",
                    "type": "apply",
                    "key": "fill",
                    "op": {
                        "module_name": "sequences.js",
                        "type": "splice",
                        "pos":1,
                        "old_value": "FFF",         // <--
                        "new_value": "1",           // <--
                        "global_order":null
                    }
                }
            }
        }
    },
    {
        "module_name": "sequences.js",
        "type": "apply",
        "pos":0,
        "op": {
            "module_name": "objects.js",
            "type": "apply",
            "key": "element",
            "op": {
                "module_name": "objects.js",
                "type": "apply",
                "key": "attrs",
                "op": {
                    "module_name": "objects.js",
                    "type": "apply",
                    "key": "fill",
                    "op": {
                        "module_name": "sequences.js",
                        "type": "splice",
                        "pos":2,
                        "old_value": "",                // <--
                        "new_value": "2",           // <--
                        "global_order":null
                    }
                }
            }
        }
    }
];

// assert.deepEqual(
//  base.compose( e[0], e[1] ),
//  {
//      "module_name": "sequences.js",
//      "type": "apply",
//      "pos":0,
//      "op": {
//          "module_name": "objects.js",
//          "type": "apply",
//          "key": "element",
//          "op": {
//              "module_name": "objects.js",
//              "type": "apply",
//              "key": "attrs",
//              "op": {
//                  "module_name": "objects.js",
//                  "type": "apply",
//                  "key": "fill",
//                  "op": {
//                      "module_name": "sequences.js",
//                      "type": "splice",
//                      "pos":1,
//                      "old_value": "",                // <--
//                      "new_value": "12",          // <--
//                      "global_order":null
//                  }
//              }
//          }
//      }
//  }
// );

// Assert throws error, so:
console.log( base.compose( e[0], e[1] ) );

which returns:

{
    module_name: 'sequences.js',
    type: 'apply',
    pos: 0,
    op: 'objects.js'
}

Thanks!
Miro

@JoshData
Copy link
Owner

JoshData commented Dec 7, 2013

Thanks for reporting the problem! Should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants