-
Notifications
You must be signed in to change notification settings - Fork 91
Conversation
thoughts:
|
thoughts again: |
Showing the corresponding Golo code is nice, but does your code still work when the file cannot be located? Think of cases like you are running from already compiled Golo code. |
@jponge You're right, I've to check this (indeed I thought only to "dev mode") ... Some homeworks for the hollidays 😄 |
👍 |
@jponge in fact, it already works. Golo code is displayed only if golo files has been found: https://github.com/k33g/golo-lang/blob/wip-assertions/src/main/golo/assertions.golo#L86 |
Great. I'm starting a more elaborated review now. |
doc/misc.asciidoc
Outdated
|
||
=== Assertions (`gololang.Assertions`) | ||
|
||
`assert` helpers allow to declare (and test) an expected boolean condition in a program. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just say it allows... assertions, this is a well-known term 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
what do you think of #308 could we merge both approach to propose 1 testing approach? |
To me an assertions framework and a test harness are orthogonal, so perhaps @k33g can polish this PR into a nice assertion module, and @danielpetisme can take advantage of it in #308 for a test harness module. |
👍 |
src/main/golo/assertions.golo
Outdated
# this is the list of golo files in a project | ||
let goloFiles = list[] | ||
|
||
struct testsReport = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather name types with an upper camel case: TestsReport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yloiseau
ok, but when I use a function "as constructor" of the type ?
struct human = {}
function Human = |args|-> human() # I know, it's so JavaScript! :p
or perhaps, it's better to write something like that :
struct Human = {}
function humanFactory = |args|-> human()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor is already a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😛 but ✅
let lines = java.nio.file.Files.readAllLines( | ||
java.nio.file.Paths.get(currentDir()+filePathName), | ||
java.nio.charset.Charset.forName("UTF-8") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a predefined function doing this (reading a file as a list of lines (string))? If not, it could be useful to add one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have that in Predefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jponge are you sure? I can't see something like java.nio.file.Files.readAllLines
in Predefined.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s called fileToText
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, fileToText
returns a big string, not an list/iterator on lines. One thing I miss in Java vs. Python is the ease to read files:
with open("file") as f:
for line in f:
# do something with the line
which use a lazy iterator, and autoclose the file (basically create a try/finally), or
for line in sys.stdin:
# do something with line
assert
helpers allow to declare (and test) an expected boolean condition
Getting back to this one. What's the state of this PR? |
so...? |
Let's have another review soon |
Gardening my fork and create an external assertions library |
No description provided.