exercism / swift

Exercism exercises in Swift.
https://exercism.org/tracks/swift
MIT License
114 stars 158 forks source link

Windowing System tests not compiling #764

Open gaetanomatonti opened 2 months ago

gaetanomatonti commented 2 months ago

In exercise "Windowing System" there is a compile issue with the test bundle. Specifically, the testMainWindow() function contains a reference to mainWindow, a Window instance that does not exist in its scope.

/mnt/exercism-iteration/Tests/WindowingSystemTests/WindowingSystemTests.swift:20:7: error: cannot find 'mainWindow' in scope
      mainWindow.display(),
      ^~~~~~~~~~

This causes the whole exercise to fail, both locally and on the online editor.

The fix is pretty straightforward, since we only need to add the following code to the function:

let mainWindow: Window = {
  let window = Window()
  window.title = "Main Window"
  window.contents = "This is the main window"
  window.resize(to: Size(width: 400, height: 300))
  window.move(to: Position(x: 100, y: 100))
  return window
}()
landmaj commented 2 months ago

For anybody coming here due to the same error - you are supposed to create an instance of the Window class and assign it to mainWindow yourself. This is one of a few exercises where you have to read the entire instruction and implement almost everything (at least function stubs) before executing tests for the first time.