mirror of
https://github.com/enso-org/enso.git
synced 2024-11-27 06:32:30 +03:00
Convert vector elements when needed (#7271)
Adds a test case demonstrating the _use of automatic conversions_ when processing vector elements.
This commit is contained in:
parent
1d77f7cd8e
commit
724a788500
@ -2,6 +2,7 @@ from Standard.Base import all
|
||||
|
||||
import project.Semantic.Conversion.Methods
|
||||
import project.Semantic.Conversion.Types
|
||||
import project.Semantic.Conversion_Use.Hello
|
||||
|
||||
from Standard.Test import Test, Test_Suite
|
||||
import Standard.Test.Extensions
|
||||
@ -115,4 +116,11 @@ spec =
|
||||
Test.specify "should not allow currying" <|
|
||||
Panic.recover Any (Foo.from) . catch Any .to_display_text . should_equal "Conversion currying without `that` argument is not supported."
|
||||
|
||||
Test.specify "Use conversions to in Conversion_Use module" <|
|
||||
Hello.formulate [ Hello.Say "Proper", Hello.Say "Type" ] . should_equal "ProperType"
|
||||
Hello.formulate [ Foo.Value "Perform", Bar.Value "Conversion" ] . should_equal "PERFORM conversion!"
|
||||
|
||||
Hello.from (that:Foo) = Hello.Say <| (that.foo.to_case Case.Upper) + " "
|
||||
Hello.from (that:Bar) = Hello.Say <| (that.bar.to_case Case.Lower) + "!"
|
||||
|
||||
main = Test_Suite.run_main spec
|
||||
|
9
test/Tests/src/Semantic/Conversion_Use.enso
Normal file
9
test/Tests/src/Semantic/Conversion_Use.enso
Normal file
@ -0,0 +1,9 @@
|
||||
from Standard.Base import all
|
||||
|
||||
type Hello
|
||||
Say (msg:Text)
|
||||
|
||||
formulate : Vector Hello -> Text
|
||||
formulate arr =
|
||||
process (t:Text) (h:Hello) = t + h.msg
|
||||
arr.fold "" process
|
Loading…
Reference in New Issue
Block a user