Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doAssertRaises improvements; nimscript supports except Exception as e #15765

Merged
merged 9 commits into from
Nov 12, 2020

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Oct 28, 2020

  • doAssertRaises now correctly handles foreign exceptions
  • now shows which exception is raised on mismatch
  • now allows to specify that we expect a foreign exception
  • nimscript now handles except Exception as e
{.emit:"""
#include <stdexcept>
void fn(){
  throw std::runtime_error("asdf");
}
""".}

proc fn(){.importcpp.}

proc main() =
  # ok
  doAssertRaises(void): fn() # ok
  doAssertRaises(AssertionDefect): doAssert false
  doAssertRaises(Exception): raise newException(Exception, "")
  doAssertRaises(Exception): doAssert false

  # these will raise AssertionDefect
  when false:
    doAssertRaises(Exception): fn() # expected raising 'Exception', instead raised foreign exception by:
    doAssertRaises(CatchableError): fn() # expected raising 'CatchableError', instead raised foreign exception by:
    doAssertRaises(CatchableError): doAssert false # expected raising 'CatchableError', instead raised 'AssertionDefect' by:
    doAssertRaises(void): doAssert false # expected raising 'foreign exception', instead raised 'AssertionDefect' by:

main()

@timotheecour timotheecour changed the title doAssertRaises now correctly handles foreign exceptions; now shows which exception is raised on mismatch doAssertRaises now correctly handles foreign exceptions and shows which exception is raised on mismatch Oct 28, 2020
@timotheecour timotheecour changed the title doAssertRaises now correctly handles foreign exceptions and shows which exception is raised on mismatch doAssertRaises improvements; nimscript supports except Exception as e Oct 28, 2020
@timotheecour timotheecour changed the title doAssertRaises improvements; nimscript supports except Exception as e doAssertRaises improvements; nimscript supports except Exception as e Oct 28, 2020
@timotheecour timotheecour requested a review from Araq October 30, 2020 19:51
lib/system/assertions.nim Outdated Show resolved Hide resolved
@timotheecour timotheecour force-pushed the pr_doAssertRaises_context branch from 1af1b70 to f8b7583 Compare November 7, 2020 00:36
@timotheecour
Copy link
Member Author

timotheecour commented Nov 7, 2020

@Araq PTAL, see #15765 (comment)

changelog.md Show resolved Hide resolved
@timotheecour timotheecour force-pushed the pr_doAssertRaises_context branch from f8b7583 to 62a481e Compare November 9, 2020 16:54
@timotheecour timotheecour force-pushed the pr_doAssertRaises_context branch from 62a481e to d15a7d3 Compare November 10, 2020 16:23
@timotheecour
Copy link
Member Author

PTAL, removed overload from this PR

@Araq Araq merged commit e5db531 into nim-lang:devel Nov 12, 2020
@timotheecour timotheecour deleted the pr_doAssertRaises_context branch November 12, 2020 17:27
PMunch pushed a commit to PMunch/Nim that referenced this pull request Jan 6, 2021
…e` (nim-lang#15765)

* doAssertRaises now correctly handles foreign exceptions; now shows which exception is raised on mismatch
* nimscript now handles `Exception as e`
* remove catch-all doAssertRaises overload from this PR

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
…e` (nim-lang#15765)

* doAssertRaises now correctly handles foreign exceptions; now shows which exception is raised on mismatch
* nimscript now handles `Exception as e`
* remove catch-all doAssertRaises overload from this PR

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
irdassis pushed a commit to irdassis/Nim that referenced this pull request Mar 16, 2021
…e` (nim-lang#15765)

* doAssertRaises now correctly handles foreign exceptions; now shows which exception is raised on mismatch
* nimscript now handles `Exception as e`
* remove catch-all doAssertRaises overload from this PR

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
…e` (nim-lang#15765)

* doAssertRaises now correctly handles foreign exceptions; now shows which exception is raised on mismatch
* nimscript now handles `Exception as e`
* remove catch-all doAssertRaises overload from this PR

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants