Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Assertion helpers #360

Closed
wants to merge 4 commits into from
Closed

Assertion helpers #360

wants to merge 4 commits into from

Conversation

k33g
Copy link
Contributor

@k33g k33g commented Feb 8, 2016

No description provided.

@k33g
Copy link
Contributor Author

k33g commented Feb 9, 2016

thoughts:
perhaps, it would be better to use:

  • assert keyword when it caused an exception and exit
  • validate keyword when it doesn't exit and provides an error object through the error callback
    ??

@k33g
Copy link
Contributor Author

k33g commented Feb 9, 2016

thoughts again:
when I display the content of the line (when error), perhaps, should I display the previous line and the next line

@k33g
Copy link
Contributor Author

k33g commented Feb 9, 2016

assertions in action:
assert

@jponge
Copy link
Contributor

jponge commented Feb 10, 2016

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.

@k33g
Copy link
Contributor Author

k33g commented Feb 10, 2016

@jponge You're right, I've to check this (indeed I thought only to "dev mode") ... Some homeworks for the hollidays 😄

@jponge
Copy link
Contributor

jponge commented Feb 10, 2016

👍

@k33g
Copy link
Contributor Author

k33g commented Feb 11, 2016

@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

@jponge
Copy link
Contributor

jponge commented Feb 12, 2016

Great. I'm starting a more elaborated review now.


=== Assertions (`gololang.Assertions`)

`assert` helpers allow to declare (and test) an expected boolean condition in a program.
Copy link
Contributor

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 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielpetisme
Copy link
Contributor

what do you think of #308 could we merge both approach to propose 1 testing approach?
Thoughts?

@jponge
Copy link
Contributor

jponge commented Feb 16, 2016

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.

@danielpetisme
Copy link
Contributor

👍
Just want to be sure the assertion framework will be test harness compliant (and no big overlap).

# this is the list of golo files in a project
let goloFiles = list[]

struct testsReport = {
Copy link
Contributor

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

Copy link
Contributor Author

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() 

?

Copy link
Contributor

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.

Copy link
Contributor Author

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")
)
Copy link
Contributor

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!

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s called fileToText

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🚫 ?

Copy link
Contributor

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

@jponge jponge changed the title assert helpers allow to declare (and test) an expected boolean condition Assertion helpers Apr 4, 2016
@jponge
Copy link
Contributor

jponge commented Apr 4, 2016

Getting back to this one.

What's the state of this PR?

@k33g
Copy link
Contributor Author

k33g commented May 5, 2016

so...?

@jponge
Copy link
Contributor

jponge commented May 5, 2016

Let's have another review soon

@jponge jponge self-assigned this May 11, 2016
@k33g
Copy link
Contributor Author

k33g commented Apr 22, 2017

Gardening my fork and create an external assertions library

@k33g k33g closed this Apr 22, 2017
@k33g k33g deleted the wip-assertions branch April 22, 2017 11:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants