SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
287 stars 25 forks source link

Support NewRecord expressions #110

Closed GoogleCodeExporter closed 5 years ago

GoogleCodeExporter commented 9 years ago
Support Patterns.NewRecord expressions. This should be pretty straight forward.

Original issue reported on code.google.com by stephen....@gmail.com on 23 Mar 2015 at 6:38

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 23 Mar 2015 at 6:39

GoogleCodeExporter commented 9 years ago
Well, actually will take a bit of work. Consider the following FSI session 
(note difference in quotation AST depending on order of args):

> type R1 = { A:int; B:int };;

type R1 =
  {A: int;
   B: int;}

> unquote <@ { A=1;B=2 } @>;;
val it : UnquotedExpression =

NewRecord (R1, Value (1), Value (2))
{A = 1;
 B = 2;}

> unquote <@ { A=1+2;B=2+3+4 } @>;;
val it : UnquotedExpression =

NewRecord (R1, Call (None, op_Addition, [Value (1), Value (2)]),
           Call (None, op_Addition,
                 [Call (None, op_Addition, [Value (2), Value (3)]), Value (4)]))
NewRecord (R1, Value (3), Call (None, op_Addition, [Value (5), Value (4)]))
NewRecord (R1, Value (3), Value (9))
{A = 3;
 B = 9;}

> unquote <@ { B=2+3+4; A=1+2 } @>;;
val it : UnquotedExpression =

let B = 2 + 3 + 4 in NewRecord (R1, Call (None, op_Addition, [Value (1), Value 
(2)]), B)
let B = 5 + 4 in NewRecord (R1, Call (None, op_Addition, [Value (1), Value 
(2)]), B)
let B = 9 in NewRecord (R1, Call (None, op_Addition, [Value (1), Value (2)]), B)
{A = 3;
 B = 9;}

Original comment by stephen....@gmail.com on 9 Apr 2015 at 2:32

thinkbeforecoding commented 5 years ago

This is addressed by #150 👍

stephen-swensen commented 5 years ago

Complete and merged into fs46 branch / PR