diff --git a/src/CSharpMinifier/Token.cs b/src/CSharpMinifier/Token.cs index f2bf2d9..4308dec 100644 --- a/src/CSharpMinifier/Token.cs +++ b/src/CSharpMinifier/Token.cs @@ -52,6 +52,9 @@ public static TokenKindTraits GetTraits(this TokenKind kind) ? TraitsByKind[i] : throw new ArgumentOutOfRangeException(nameof(kind)); } + + public static bool HasTraits(this TokenKind kind, TokenKindTraits traits) => + (kind.GetTraits() & traits) == traits; } public readonly struct Token : IEquatable diff --git a/tests/TokenKindTests.cs b/tests/TokenKindTests.cs index 5d2fb53..a1bdbdb 100644 --- a/tests/TokenKindTests.cs +++ b/tests/TokenKindTests.cs @@ -44,7 +44,9 @@ public class TokenKindTests public void Traits(TokenKind kind, TokenKindTraits traits) { - Assert.That(kind.GetTraits(), Is.EqualTo(traits)); + Assert.That(kind.GetTraits() , Is.EqualTo(traits)); + Assert.That(kind.HasTraits(traits) , Is.True); + Assert.That(kind.HasTraits(~traits), Is.False); } [Test]