Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Oct 24, 2024
1 parent 1373e07 commit 0902963
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/Fabulous.Tests/APISketchTests/APISketchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -642,29 +642,29 @@ module Issue104 =

let ControlWidgetKey = Widgets.register<TestButton>()

let Control<'msg> () =
let Control () =
WidgetBuilder<'msg, TestButtonMarker>(ControlWidgetKey, AttributesBundle(StackList.StackList.empty(), ValueNone, ValueNone))

[<System.Runtime.CompilerServices.Extension>]
type WidgetExtensions() =
[<System.Runtime.CompilerServices.Extension>]
static member inline attr1<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline attr1<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attr1.WithValue(value))

[<System.Runtime.CompilerServices.Extension>]
static member inline attr2<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline attr2<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attr2.WithValue(value))

[<System.Runtime.CompilerServices.Extension>]
static member inline attr3<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline attr3<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attr3.WithValue(value))

[<System.Runtime.CompilerServices.Extension>]
static member inline attr4<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline attr4<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attr4.WithValue(value))

[<System.Runtime.CompilerServices.Extension>]
static member inline attr5<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline attr5<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attr5.WithValue(value))

let view model =
Expand Down
34 changes: 17 additions & 17 deletions src/Fabulous.Tests/APISketchTests/TestUI.Widgets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,37 @@ module TestUI_Widgets =
[<Extension>]
type WidgetExtensions() =
[<Extension>]
static member inline automationId<'msg, 'marker when 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline automationId<'msg, 'marker when 'msg: equality and 'marker :> IMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attributes.Automation.AutomationId.WithValue(value))

[<Extension>]
static member inline automationId<'msg, 'marker, 'itemMarker when 'marker :> IMarker>
static member inline automationId<'msg, 'marker, 'itemMarker when 'msg: equality and 'marker :> IMarker>
(this: CollectionBuilder<'msg, 'marker, 'itemMarker>, value: string)
=
this.AddScalar(Attributes.Automation.AutomationId.WithValue(value))

[<Extension>]
static member inline textColor<'msg, 'marker when 'marker :> TextMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
static member inline textColor<'msg, 'marker when 'msg: equality and 'marker :> TextMarker>(this: WidgetBuilder<'msg, 'marker>, value: string) =
this.AddScalar(Attributes.TextStyle.TextColor.WithValue(value))


[<Extension>]
static member inline record<'msg, 'marker when 'marker :> TestLabelMarker>(this: WidgetBuilder<'msg, 'marker>, value: bool) =
static member inline record<'msg, 'marker when 'msg: equality and 'marker :> TestLabelMarker>(this: WidgetBuilder<'msg, 'marker>, value: bool) =
this.AddScalar(Attributes.Text.Record.WithValue(value))


[<Extension>]
static member inline tap<'msg, 'marker when 'marker :> TestButtonMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
static member inline tap<'msg, 'marker when 'msg: equality and 'marker :> TestButtonMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
this.AddScalar(Attributes.Button.Tap.WithValue(value))


[<Extension>]
static member inline tap2<'msg, 'marker when 'marker :> TestButtonMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
static member inline tap2<'msg, 'marker when 'msg: equality and 'marker :> TestButtonMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
this.AddScalar(Attributes.Button.Tap2.WithValue(value))


[<Extension>]
static member inline tapContainer<'msg, 'marker when 'marker :> TestStackMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
static member inline tapContainer<'msg, 'marker when 'msg: equality and 'marker :> TestStackMarker>(this: WidgetBuilder<'msg, 'marker>, value: 'msg) =
this.AddScalar(Attributes.Container.Tap.WithValue(value))

///----------------
Expand All @@ -125,22 +125,22 @@ module TestUI_Widgets =
static let TestStackKey = Widgets.register<TestStack>()
static let TestNumericBagKey = Widgets.register<TestNumericBag>()

static member Label<'msg>(text: string) =
static member Label(text: string) =
WidgetBuilder<'msg, TestLabelMarker>(TestLabelKey, Attributes.Text.Text.WithValue(text))


static member Button<'msg>(text: string, onClicked: 'msg) =
static member Button(text: string, onClicked: 'msg) =
WidgetBuilder<'msg, TestButtonMarker>(TestButtonKey, Attributes.Text.Text.WithValue(text), Attributes.Button.Pressed.WithValue(onClicked))

static member BoxedNumericBag<'msg>(one, two, three) =
static member BoxedNumericBag(one, two, three) =
WidgetBuilder<'msg, TestNumericBagMarker>(
TestNumericBagKey,
Attributes.NumericBag.BoxedValueOne.WithValue(one),
Attributes.NumericBag.BoxedValueTwo.WithValue(two),
Attributes.NumericBag.BoxedValueThree.WithValue(three)
)

static member InlineNumericBag<'msg>(one, two, three) =
static member InlineNumericBag(one, two, three) =
WidgetBuilder<'msg, TestNumericBagMarker>(
TestNumericBagKey,
Attributes.NumericBag.InlineValueOne.WithValue(one, (fun x -> x)),
Expand All @@ -150,25 +150,25 @@ module TestUI_Widgets =
Attributes.NumericBag.InlineValueThree.WithValue(three, BitConverter.DoubleToUInt64Bits)
)

static member Stack<'msg, 'marker when 'marker :> IMarker>() =
static member Stack<'msg, 'marker when 'msg: equality and 'marker :> IMarker>() =
CollectionBuilder<'msg, TestStackMarker, 'marker>(TestStackKey, StackList.empty(), Attributes.Container.Children)

[<Extension>]
type CollectionBuilderExtensions =
[<Extension>]
static member inline Yield<'msg, 'marker, 'itemMarker when 'itemMarker :> IMarker>
static member inline Yield<'msg, 'marker, 'itemMarker when 'msg: equality and 'itemMarker :> IMarker>
(_: CollectionBuilder<'msg, 'marker, IMarker>, x: WidgetBuilder<'msg, 'itemMarker>)
: Content<'msg> =
CollectionBuilder.yieldImpl x

[<Extension>]
static member inline Yield<'msg, 'marker, 'itemMarker when 'itemMarker :> IMarker>
static member inline Yield<'msg, 'marker, 'itemMarker when 'msg: equality and 'itemMarker :> IMarker>
(_: CollectionBuilder<'msg, 'marker, IMarker>, x: WidgetBuilder<'msg, Memo.Memoized<'itemMarker>>)
: Content<'msg> =
CollectionBuilder.yieldImpl x

[<Extension>]
static member inline YieldFrom<'msg, 'marker, 'itemMarker when 'itemMarker :> IMarker>
static member inline YieldFrom<'msg, 'marker, 'itemMarker when 'msg: equality and 'itemMarker :> IMarker>
(_: CollectionBuilder<'msg, 'marker, IMarker>, x: WidgetBuilder<'msg, 'itemMarker> seq)
: Content<'msg> =
// TODO optimize this one with addMut
Expand All @@ -178,7 +178,7 @@ module TestUI_Widgets =


///------------------
type StatefulView<'arg, 'model, 'msg, 'marker> =
type StatefulView<'arg, 'model, 'msg, 'marker when 'msg: equality> =
{ Init: 'arg -> 'model
Update: 'msg -> 'model -> 'model
View: 'model -> WidgetBuilder<'msg, 'marker> }
Expand All @@ -191,7 +191,7 @@ module TestUI_Widgets =


module Run =
type Instance<'arg, 'model, 'msg, 'marker>(program: StatefulView<'arg, 'model, 'msg, 'marker>) =
type Instance<'arg, 'model, 'msg, 'marker when 'msg: equality>(program: StatefulView<'arg, 'model, 'msg, 'marker>) =
let mutable state: ('model * obj * Widget) option = None

member private x.viewContext: ViewTreeContext =
Expand Down

0 comments on commit 0902963

Please sign in to comment.