Created
September 18, 2011 16:44
-
-
Save krawaller/1225255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tests.addBatch "the calc function": | |
"is defined": -> assert.isFunction calc | |
"when relating": | |
topic: -> (arg)-> calc "relation", start, arg, "eq" | |
"a blob": | |
topic: (relate)-> relate blob | |
"we get a": type "relation" | |
"containing": objs [start, blob] | |
"with a value": val "eq" | |
"a relation": (relate)-> assert.throws -> relate relation | |
"when adding": | |
topic: -> (arg)-> calc "sum", start, arg | |
"a blob": | |
topic: (add)-> add blob | |
"we get a": type "sum" | |
"containing": objs [start,blob] | |
"a sum": | |
topic: (add)-> add sum | |
"we get a": type "sum" | |
"containing": objs [start].concat sum.objs | |
"a sum that is a block": | |
topic: (add)-> add blocksum | |
"we get a": type "sum" | |
"containing": objs [start,blocksum] | |
"a relation": | |
topic: (add)-> add relation | |
"we get a": type "relation" | |
"containing": objs [o("sum",[start,relation.objs[0]]), relation.objs[1]] | |
"with a value": (o)-> assert.equal o.val, relation.val | |
"a product": | |
topic: (add)-> add product | |
"we get a": type "sum" | |
"when multiplying": | |
topic: -> (arg)-> calc "product", start, arg | |
"a relation": | |
topic: (mult)-> mult relation | |
"we get a": type "relation" | |
"containing": objs [o("product",[start,relation.objs[0]]), relation.objs[1]] | |
"with a value": (o)-> assert.equal o.val, relation.val | |
"a blob": | |
topic: (mult)-> mult blob | |
"we get a": type "product" | |
"containing": objs [start, blob] | |
"a sum that is a block": | |
topic: (mult)-> mult blocksum | |
"we get a": type "product" | |
"containing": objs [start, blocksum] | |
"a sum": | |
topic: (mult)-> mult sum | |
"we get a": type "sum" | |
"containing": objs [o("product",[start,sum.objs[0]])].concat(sum.objs[1..]) | |
"a sum starting with a blockproduct": | |
topic: (mult)-> mult Sum blockproduct, three | |
"we get a": type "sum" | |
"containing": objs [Product(start,blockproduct), three] | |
"a sum starting with a nonblock product": | |
topic: (mult)-> mult Sum Product(two,three), four | |
"we get a": type "sum" | |
"containing": objs [Product(start,two,three), four] | |
"a product": | |
topic: (mult)-> mult product | |
"we get a": type "product" | |
"containing": objs [start].concat product.objs | |
"a product that is a block": | |
topic: (mult)-> mult blockproduct | |
"we get a": type "product" | |
"containing": objs [start, blockproduct] | |
"when dividing": | |
topic: -> (arg)-> calc "fraction", start, arg | |
"a blob": | |
topic: (div)-> div blob | |
"we get a": type "fraction" | |
"containing": objs [start,blob] | |
"a relation": | |
topic: (div)-> div relation | |
"we get a": type "relation" | |
"containing": objs [o("fraction",[start,relation.objs[0]]),relation.objs[1]] | |
"with a value": (o)-> assert.equal o.val, relation.val | |
"a sum": | |
topic: (div)-> div sum | |
"we get a": type "sum" | |
"containing": objs [o("fraction",[start,sum.objs[0]])].concat(sum.objs[1..]) | |
"a sum that is a block": | |
topic: (div)-> div blocksum | |
"we get a": type "fraction" | |
"containing": objs [start,blocksum] | |
"a product": | |
topic: (div)-> div product | |
"we get a": type "product" | |
"containing": objs [o("fraction",[start,product.objs[0]])].concat(product.objs[1..]) | |
"a product that is a block": | |
topic: (div)-> div blockproduct | |
"we get a": type "fraction" | |
"containing": objs [start,blockproduct] | |
"when raising": | |
topic: -> (arg)-> calc "power", start, arg | |
"a blob": | |
topic: (power)-> power blob | |
"we get a": type "power" | |
"containing": objs [start,blob] | |
"a relation": | |
topic: (power)-> power relation | |
"we get a": type "relation" | |
"containing": objs [o("power",[start,relation.objs[0]]),relation.objs[1]] | |
"with a value": (o)-> assert.equal o.val, relation.val | |
"a sum": | |
topic: (power)-> power sum | |
"we get a": type "sum" | |
"containing": objs [o("power",[start,sum.objs[0]])].concat(sum.objs[1..]) | |
"a sum that is a block": | |
topic: (power)-> power blocksum | |
"we get a": type "power" | |
"containing": objs [start,blocksum] | |
"a product": | |
topic: (power)-> power product | |
"we get a": type "product" | |
"containing": objs [o("power",[start,product.objs[0]])].concat(product.objs[1..]) | |
"a product that is a block": | |
topic: (power)-> power blockproduct | |
"we get a": type "power" | |
"containing": objs [start,blockproduct] | |
"a fraction": | |
topic: (power)-> power fraction | |
"we get a": type "fraction" | |
"containing": objs [o("power",[start,fraction.objs[0]]),fraction.objs[1]] | |
"a fraction that is a block": | |
topic: (power)-> power blockfraction | |
"we get a": type "power" | |
"containing": objs [start,blockfraction] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment