@@ -228,23 +228,38 @@ module.exports = perspective => {
228228 table . delete ( ) ;
229229 } ) ;
230230
231- it ( "Should be able to create multiple computed columns in multiple `view()`s" , async function ( ) {
231+ it ( "Should be able to create multiple computed columns with unique names in multiple `view()`s" , async function ( ) {
232232 const table = perspective . table ( common . int_float_data ) ;
233233 const view = table . view ( {
234234 computed_columns : [
235235 {
236236 column : "float + int" ,
237237 computed_function_name : "+" ,
238238 inputs : [ "w" , "x" ]
239+ } ,
240+ {
241+ column : "float - int" ,
242+ computed_function_name : "-" ,
243+ inputs : [ "w" , "x" ]
244+ } ,
245+ {
246+ column : "float * int" ,
247+ computed_function_name : "*" ,
248+ inputs : [ "w" , "x" ]
239249 }
240250 ]
241251 } ) ;
242252 const view2 = table . view ( {
243253 computed_columns : [
244254 {
245- column : "float - int" ,
246- computed_function_name : "- " ,
255+ column : "float / int" ,
256+ computed_function_name : "/ " ,
247257 inputs : [ "w" , "x" ]
258+ } ,
259+ {
260+ column : "int * float" ,
261+ computed_function_name : "*" ,
262+ inputs : [ "x" , "w" ]
248263 }
249264 ]
250265 } ) ;
@@ -257,15 +272,18 @@ module.exports = perspective => {
257272 x : "integer" ,
258273 y : "string" ,
259274 z : "boolean" ,
260- "float + int" : "float"
275+ "float + int" : "float" ,
276+ "float - int" : "float" ,
277+ "float * int" : "float"
261278 } ) ;
262279
263280 expect ( schema2 ) . toEqual ( {
264281 w : "float" ,
265282 x : "integer" ,
266283 y : "string" ,
267284 z : "boolean" ,
268- "float - int" : "float"
285+ "float / int" : "float" ,
286+ "int * float" : "float"
269287 } ) ;
270288
271289 const result = await view . to_columns ( ) ;
@@ -276,15 +294,18 @@ module.exports = perspective => {
276294 x : [ 1 , 2 , 3 , 4 ] ,
277295 y : [ "a" , "b" , "c" , "d" ] ,
278296 z : [ true , false , true , false ] ,
279- "float + int" : [ 2.5 , 4.5 , 6.5 , 8.5 ]
297+ "float + int" : [ 2.5 , 4.5 , 6.5 , 8.5 ] ,
298+ "float - int" : [ 0.5 , 0.5 , 0.5 , 0.5 ] ,
299+ "float * int" : [ 1.5 , 5 , 10.5 , 18 ]
280300 } ) ;
281301
282302 expect ( result2 ) . toEqual ( {
283303 w : [ 1.5 , 2.5 , 3.5 , 4.5 ] ,
284304 x : [ 1 , 2 , 3 , 4 ] ,
285305 y : [ "a" , "b" , "c" , "d" ] ,
286306 z : [ true , false , true , false ] ,
287- "float - int" : [ 0.5 , 0.5 , 0.5 , 0.5 ]
307+ "float / int" : [ 1.5 , 1.25 , 1.1666666666666667 , 1.125 ] ,
308+ "int * float" : [ 1.5 , 5 , 10.5 , 18 ]
288309 } ) ;
289310
290311 view2 . delete ( ) ;
@@ -334,6 +355,9 @@ module.exports = perspective => {
334355
335356 view . delete ( ) ;
336357
358+ // force a process()
359+ expect ( await table . size ( ) ) . toEqual ( 4 ) ;
360+
337361 const schema2 = await view2 . schema ( ) ;
338362
339363 expect ( schema2 ) . toEqual ( {
@@ -408,6 +432,9 @@ module.exports = perspective => {
408432
409433 const schema2 = await view2 . schema ( ) ;
410434
435+ // force a process()
436+ expect ( await table . size ( ) ) . toEqual ( 4 ) ;
437+
411438 expect ( schema2 ) . toEqual ( {
412439 w : "float" ,
413440 x : "integer" ,
@@ -549,7 +576,7 @@ module.exports = perspective => {
549576 table . delete ( ) ;
550577 } ) ;
551578
552- it ( "A view without computed columns should break when serializing after another view with a computed column is deleted ." , async function ( ) {
579+ it ( "A view without computed columns should not serialize computed columns from other views ." , async function ( ) {
553580 const table = perspective . table ( common . int_float_data ) ;
554581 const view = table . view ( {
555582 computed_columns : [
@@ -802,7 +829,7 @@ module.exports = perspective => {
802829 table . delete ( ) ;
803830 } ) ;
804831
805- it ( "Should be able to row pivot on a non-computed column and get correct results." , async function ( ) {
832+ it ( "Should be able to row pivot on a non-computed column and get correct results for the computed column ." , async function ( ) {
806833 const table = perspective . table ( common . int_float_data ) ;
807834 const view = table . view ( {
808835 row_pivots : [ "w" ] ,
0 commit comments