diff --git a/tests/WebSharper.Tests/ASTTests.fsx b/tests/WebSharper.Tests/ASTTests.fsx index 17b9424f..91da5153 100644 --- a/tests/WebSharper.Tests/ASTTests.fsx +++ b/tests/WebSharper.Tests/ASTTests.fsx @@ -28,8 +28,6 @@ #r "../../build/Release/netstandard2.0/WebSharper.Core.dll" #r "../../build/Release/netstandard2.0/WebSharper.JavaScript.dll" #r "../../build/Release/netstandard2.0/WebSharper.Main.dll" -#r "../../build/Release/netstandard2.0/WebSharper.MathJS.dll" -#r "../../build/Release/netstandard2.0/WebSharper.MathJS.Extensions.dll" #r "../../build/Release/netstandard2.0/WebSharper.Collections.dll" #r "../../build/Release/netstandard2.0/WebSharper.Control.dll" #r "../../build/Release/netstandard2.0/WebSharper.Web.dll" @@ -288,8 +286,6 @@ let wsRefs = "WebSharper.Collections" "WebSharper.Control" "WebSharper.Web" - "WebSharper.MathJS" - "WebSharper.MathJS.Extensions" "WebSharper.Testing" //"WebSharper.Sitelets" //"WebSharper.Tests" @@ -440,11 +436,14 @@ let translate isBundle source = //printfn "trimmedMeta: %A" trimmedMeta - let pkg = WebSharper.Compiler.JavaScriptPackager.bundleAssembly WebSharper.Core.JavaScript.JavaScript trimmedMeta trimmedMeta "TestProject" comp.EntryPoint WebSharper.Compiler.JavaScriptPackager.OnLoadIfExists + let pkg = + WebSharper.Compiler.JavaScriptPackager.bundleAssembly WebSharper.Core.JavaScript.JavaScript trimmedMeta trimmedMeta "TestProject" comp.EntryPoint WebSharper.Compiler.JavaScriptPackager.OnLoadIfExists + let pkg, _ = + pkg |> WebSharper.Compiler.JavaScriptWriter.transformProgram WebSharper.Core.JavaScript.JavaScript WebSharper.Core.JavaScript.Readable //printfn "packaged: %s" (WebSharper.Core.AST.Debug.PrintStatement (WebSharper.Core.AST.Block pkg)) - let js, _, _ = WebSharper.Compiler.JavaScriptPackager.programToString WebSharper.Core.JavaScript.JavaScript WebSharper.Core.JavaScript.Readable WebSharper.Core.JavaScript.Writer.CodeWriter pkg + let js, _, _ = WebSharper.Compiler.JavaScriptPackager.programToString WebSharper.Core.JavaScript.Readable WebSharper.Core.JavaScript.Writer.CodeWriter pkg false printfn "%s" js else @@ -457,7 +456,8 @@ let translate isBundle source = let jsFiles = pkg |> Array.map (fun (file, p) -> - let js, _, _ = WebSharper.Compiler.JavaScriptPackager.programToString WebSharper.Core.JavaScript.JavaScript WebSharper.Core.JavaScript.Readable WebSharper.Core.JavaScript.Writer.CodeWriter p + let p, _ = p |> WebSharper.Compiler.JavaScriptWriter.transformProgram WebSharper.Core.JavaScript.JavaScript WebSharper.Core.JavaScript.Readable + let js, _, _ = WebSharper.Compiler.JavaScriptPackager.programToString WebSharper.Core.JavaScript.Readable WebSharper.Core.JavaScript.Writer.CodeWriter p false file, js ) @@ -509,14 +509,22 @@ open WebSharper open WebSharper.JavaScript open System.Collections.Generic -[] -module MyTest = +[] +type Position = + { + pos_fname: string + pos_lnum: int + pos_orig_lnum: int + } + + member pos.Line = pos.pos_lnum + + member pos.NextLine = + let pos = pos + { pos with + pos_lnum = pos.Line + 1 + } - let Main() = - let f x y = x + y - let g() = - f 1 2 + f 2 3 - g() + g() """ //translate """ diff --git a/tests/WebSharper.Tests/Basis.fs b/tests/WebSharper.Tests/Basis.fs index 0533a17d..82cd0618 100644 --- a/tests/WebSharper.Tests/Basis.fs +++ b/tests/WebSharper.Tests/Basis.fs @@ -631,20 +631,19 @@ let Tests = ) } - Skip "Anonymous records" { - //let x = IM.AnonRecord({| A = 42 |}) - //equal x.B 42 - //equal {| x with C = 3|} (New ["B" => 42; "C" => 3]) - //let a, b = - // match IM.AnonRecordInUnion() with - // | IM.AnonRecordTest r -> r.A, r.B - //equal a 3 - //equal b "hi" - //equal {| A = 1; B = ValueNone; C = ValueSome 3 |} (New ["A" => 1; "C" => 3]) - //equal {| A = 1; B = None; C = Some 3 |} (New ["A" => 1; "C" => 3]) - //let s = struct {| A = 5 |} - //equal s.A 5 - expect 0 + Test "Anonymous records" { + let x = IM.AnonRecord({| A = 42 |}) + equal x.B 42 + equal {| x with C = 3|} (New ["B" => 42; "C" => 3]) + let a, b = + match IM.AnonRecordInUnion() with + | IM.AnonRecordTest r -> r.A, r.B + equal a 3 + equal b "hi" + equal {| A = 1; B = ValueNone; C = ValueSome 3 |} (New ["A" => 1; "C" => 3]) + equal {| A = 1; B = None; C = Some 3 |} (New ["A" => 1; "C" => 3]) + let s = struct {| A = 5 |} + equal s.A 5 } Test "Implicit yield" { diff --git a/tests/WebSharper.Tests/Object.fs b/tests/WebSharper.Tests/Object.fs index 0003575b..49754372 100644 --- a/tests/WebSharper.Tests/Object.fs +++ b/tests/WebSharper.Tests/Object.fs @@ -137,6 +137,22 @@ type StructRecord = type StructRecord2 = { SR2 : int; SR2b : string } +[] +type Position = + { + pos_fname: string + pos_lnum: int + pos_orig_lnum: int + } + + member pos.Line = pos.pos_lnum + + member pos.NextLine = + let pos = pos + { pos with + pos_lnum = pos.Line + 1 + } + [] type U = | U0