WindowingSystem exercise - broken tests?

Hi all,

I’ve really been enjoying using exercise to learn Swift over the last few weeks. I’m working my way through the syllabus and am stuck at the Windowing System exercise.

Obviously, I’m new, so I’m probably doing something wrong. One of the tasks directs you to create an instance of Window and call some class methods on the instance to modify it. I am able to create the instance. However, every attempt to modify it results in an error:

/mnt/exercism-iteration/Sources/WindowingSystem/WindowingSystem.swift:82:1: error: expressions are not allowed at the top level mainWindow.update(title: "Main Window") ^ /mnt/exercism-iteration/Sources/WindowingSystem/WindowingSystem.swift:82:1: error: expressions are not allowed at the top level mainWindow.update(title: "Main Window") ^ error: fatalError

I’d love any suggestions on what’s going on. I feel like it is not related to my code, but maybe that’s just the optimistic newbie in me. :)

A second problem I’ve seen (on the same exercise) is that when a test fails, the expected value in the TEST FAILURE output section is different from the real expected value. You can see the real expected value in the top half of the screenshot.

Thanks for any help!

1 Like

For you first question what you are suppose to do is to deffine a clousure more explict an Closures, they allow you to execute code withouit making a function, and they can be assaigned to a variable or constant.

I am not intending it to be this way, but I am working on other stuff, this is on my list and I have been aware of it, but it is not my priority mostly because it is quite far down in the syllabus tree. And at the moment I am prioritizng the beging.

As for your second question, I dont know why that is happening, the “-” at the end of the message says to me that it is not on our side. But I will do a double check. In general the test runner was rewritten for 1-2 months ago, being totally remasterd with better stabillty and new functionally. It is production ready but it still has some few things I like to patch, it did recive I think 3 patches since it launch and I will likely do another one in septemeber.

Alright yeah, something is up with the messaging part here, I think I made a fix a while back but didnt seem to have cover everything. Will try to make a patch under the weekend to fix it, but the messaging system is not part of the actuall test logic. So the test logic is working as intended.

I agree - the test logic is working as intended.

I’ll look at closures, thanks!

Alright I have made a pr with a patch, but only to fix this issue. The test runner missed picking up the last line for multi line strings, but with this update it should be fixed. I dont know when it will be merged but I wouldnt expect it to be merged until next week, but thanks for reporting.

Hi there – I’m hitting the same problem as the first question in the thread: the test logic expects to find mainWindow but I can’t put it at the top level and then mutate it with the methods as task 7 requests

how can I get this test to pass so that I can unlock the rest of the syllabus? the answer from Meatball says to use a closure, but I don’t understand where the closure would be stored or how it would ever get called

would it be welcome for me to send a PR that changed it so that the student was asked to define a top-level function called makeMainWindow that returned the expected value? I’m not sure how else this could ever work