-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue-114] Add test to sequential driver on same signal to return Ex…
…ception (#197)
- Loading branch information
Showing
21 changed files
with
486 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
export 'duplicate_detection_set.dart'; | ||
export 'traverseable_collection.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
/// | ||
/// redriven_monitor_set.dart | ||
/// A set that monitor for duplication. | ||
/// | ||
/// 2022 November 2 | ||
/// Author: Yao Jing Quek <[email protected]> | ||
/// | ||
import 'dart:collection'; | ||
import 'dart:core'; | ||
|
||
import 'package:collection/collection.dart'; | ||
|
||
/// A Set collection that monitor for duplication. | ||
/// | ||
/// The [DuplicateDetectionSet] is used to identify | ||
/// duplicate elements in the Set. | ||
class DuplicateDetectionSet<T> extends SetBase<T> { | ||
/// The [Set] which contains unique values. | ||
final Set<T> _set = <T>{}; | ||
|
||
/// The [Set] which contains duplicate values. | ||
final Set<T> _duplicates = <T>{}; | ||
|
||
@override | ||
bool add(T value) { | ||
if (_set.contains(value)) { | ||
_duplicates.add(value); | ||
} | ||
|
||
return _set.add(value); | ||
} | ||
|
||
@override | ||
void addAll(Iterable<T> elements) { | ||
elements.forEach(add); | ||
} | ||
|
||
/// The duplicate members in the collection | ||
/// | ||
/// Returns an [UnmodifiableSetView] from DuplicateDetectionSet collection | ||
Set<T> get duplicates => UnmodifiableSetView(_duplicates); | ||
|
||
/// Returns `true` if collection contains duplicates | ||
bool get hasDuplicates => _duplicates.isNotEmpty; | ||
|
||
@override | ||
bool contains(Object? element) => _set.contains(element); | ||
|
||
@override | ||
Iterator<T> get iterator => _set.iterator; | ||
|
||
@override | ||
int get length => _set.length; | ||
|
||
@override | ||
T? lookup(Object? element) => _set.lookup(element); | ||
|
||
/// Removes value from [DuplicateDetectionSet] collection. | ||
/// | ||
/// The [value] in [DuplicateDetectionSet] must not contain duplicates. | ||
/// An [Exception] will be thrown if duplicates [value] found. | ||
@override | ||
bool remove(Object? value) { | ||
if (_set.contains(value) && _duplicates.contains(value)) { | ||
throw Exception('Duplication value detected inside Set!'); | ||
} | ||
return _set.remove(value); | ||
} | ||
|
||
@override | ||
Set<T> toSet() => _set; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
export 'signal_redriven_exception.dart'; |
28 changes: 28 additions & 0 deletions
28
lib/src/exceptions/conditionals/signal_redriven_exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
/// | ||
/// signal_redriven_exception.dart | ||
/// An exception that thrown when a signal is | ||
/// redriven multiple times. | ||
/// | ||
/// 2022 November 9 | ||
/// Author: Yao Jing Quek <[email protected]> | ||
import 'package:rohd/rohd.dart'; | ||
|
||
/// An exception that thrown when a [Logic] signal is | ||
/// operated multiple times. | ||
class SignalRedrivenException implements Exception { | ||
late final String _message; | ||
|
||
/// Displays [signals] that are driven multiple times | ||
/// with default error [message]. | ||
/// | ||
/// Creates a [SignalRedrivenException] with an optional error [message]. | ||
SignalRedrivenException(String signals, | ||
[String message = 'Sequential drove the same signal(s) multiple times: ']) | ||
: _message = message + signals; | ||
|
||
@override | ||
String toString() => _message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
export 'name_exceptions.dart'; | ||
export './conditionals/conditional_exceptions.dart'; | ||
export './name/name_exceptions.dart'; | ||
export './sim_compare/sim_compare_exceptions.dart'; |
26 changes: 26 additions & 0 deletions
26
lib/src/exceptions/name/invalid_reserved_name_exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
/// | ||
/// invalid_reserved_name_exception.dart | ||
/// An exception that thrown when a reserved name is invalid. | ||
/// | ||
/// 2022 October 25 | ||
/// Author: Yao Jing Quek <[email protected]> | ||
/// | ||
/// An exception that thrown when a reserved name is invalid. | ||
class InvalidReservedNameException implements Exception { | ||
late final String _message; | ||
|
||
/// Display error [message] on invalid reserved name. | ||
/// | ||
/// Creates a [InvalidReservedNameException] with an optional error [message]. | ||
InvalidReservedNameException( | ||
[String message = 'Reserved Name need to follow proper naming ' | ||
'convention if reserved' | ||
' name set to true']) | ||
: _message = message; | ||
|
||
@override | ||
String toString() => _message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
export 'invalid_reserved_name_exception.dart'; | ||
export 'null_reserved_name_exception.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
/// | ||
/// null_reserved_name_exception.dart | ||
/// An exception that thrown when a reserved name is `null`. | ||
/// | ||
/// 2022 November 15 | ||
/// Author: Yao Jing Quek <[email protected]> | ||
/// | ||
/// An exception that thrown when a reserved name is `null`. | ||
class NullReservedNameException implements Exception { | ||
late final String _message; | ||
|
||
/// Display error [message] on `null` reserved name. | ||
/// | ||
/// Creates a [NullReservedNameException] with an optional error [message]. | ||
NullReservedNameException( | ||
[String message = 'Reserved Name cannot be null ' | ||
'if reserved name set to true']) | ||
: _message = message; | ||
|
||
@override | ||
String toString() => _message; | ||
} |
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
lib/src/exceptions/sim_compare/non_supported_type_exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
/// | ||
/// non_supported_type_exception.dart | ||
/// An exception that thrown when `runtimetype` of expected | ||
/// vector output from SimCompare is invalid or unsupported. | ||
/// | ||
/// 2022 November 17 | ||
/// Author: Yao Jing Quek <[email protected]> | ||
/// | ||
import 'package:rohd/src/utilities/simcompare.dart'; | ||
|
||
/// An exception that thrown when `runtimeType` of expected vector | ||
/// output from [SimCompare] is invalid or unsupported. | ||
class NonSupportedTypeException implements Exception { | ||
late final String _message; | ||
|
||
/// Displays [vector] which have invalid or unsupported `runtimeType` | ||
/// with default error [message]. | ||
/// | ||
/// Creates a [NonSupportedTypeException] with an optional error [message]. | ||
NonSupportedTypeException(String vector, | ||
[String message = 'The runtimetype of expected vector is unsupported: ']) | ||
: _message = message + vector.runtimeType.toString(); | ||
|
||
@override | ||
String toString() => _message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// Copyright (C) 2022 Intel Corporation | ||
/// SPDX-License-Identifier: BSD-3-Clause | ||
export 'non_supported_type_exception.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.