Skip to content

Commit d8db531

Browse files
committed
add test
1 parent 8de6c09 commit d8db531

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

jscomp/syntax/tests/ppx/react/defaultValueProp.res

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,16 @@ module C1 = {
77
@react.component
88
let make = (~a=2, ~b) => React.int(a + b)
99
}
10+
11+
module C2 = {
12+
let a = "foo"
13+
@react.component
14+
let make = (~a=a) => React.string(a)
15+
}
16+
17+
module C3 = {
18+
@react.component
19+
let make = (~disabled as everythingDisabled: bool=false) => {
20+
React.string(everythingDisabled ? "true" : "false")
21+
}
22+
}

jscomp/syntax/tests/ppx/react/expected/defaultValueProp.res.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,42 @@ module C1 = {
3535
\"DefaultValueProp$C1"
3636
}
3737
}
38+
39+
module C2 = {
40+
let a = "foo"
41+
type props<'a> = {a?: 'a}
42+
43+
let make = ({?a, _}: props<_>) => {
44+
let a = switch a {
45+
| Some(a) => a
46+
| None => a
47+
}
48+
49+
React.string(a)
50+
}
51+
let make = {
52+
let \"DefaultValueProp$C2" = (props: props<_>) => make(props)
53+
54+
\"DefaultValueProp$C2"
55+
}
56+
}
57+
58+
module C3 = {
59+
type props<'disabled> = {disabled?: 'disabled}
60+
61+
let make = ({disabled: ?everythingDisabled, _}: props<bool>) => {
62+
let disabled = switch disabled {
63+
| Some(disabled) => disabled
64+
| None => false
65+
}
66+
67+
{
68+
React.string(everythingDisabled ? "true" : "false")
69+
}
70+
}
71+
let make = {
72+
let \"DefaultValueProp$C3" = (props: props<_>) => make(props)
73+
74+
\"DefaultValueProp$C3"
75+
}
76+
}

0 commit comments

Comments
 (0)