Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naasking/codefault
A simple testing library to check that compilation fails on code fragments
https://github.com/naasking/codefault
Last synced: 9 days ago
JSON representation
A simple testing library to check that compilation fails on code fragments
- Host: GitHub
- URL: https://github.com/naasking/codefault
- Owner: naasking
- License: lgpl-2.1
- Created: 2015-10-03T13:55:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-04T12:21:02.000Z (about 9 years ago)
- Last Synced: 2024-12-05T20:48:07.436Z (18 days ago)
- Language: C#
- Size: 613 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CodeFault
A library to check that compilation fails on code fragments:
using (var code = new Compiler("C#"))
{
code.Reference() // reference System.dll assembly
.Compile(@"
using System;class Foo where T : Delegate
{
}")
.FailsWith(code.Error("CS0702", line:4)); // Constraint cannot be special class 'Delegate'
}If the compilation does not have that error at the given line,
it will throw an exception. This allows unit testing abstractions
that are supposed to prevent certain errors at compile-time.