Skip to content

Commit

Permalink
refactor: Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmah309 committed Dec 11, 2023
1 parent 530aa70 commit 9a4dc4e
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 52 deletions.
4 changes: 1 addition & 3 deletions lib/src/cell/cell/bool_cell.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
part of 'cell.dart';

extension BoolConstCellExtensions on ConstCell<bool> {

/// Equal to
bool eq(bool val) {
return _val == val;
}
}

extension BoolCellExtensions on Cell<bool> {

/// "!" on the inner bool value. e.g. val = !val;
void not() {
_val = !_val;
}
}
}
2 changes: 1 addition & 1 deletion lib/src/cell/cell/const_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class ConstCell<T> {
String toString() {
return "$runtimeType($_val)";
}
}
}
4 changes: 0 additions & 4 deletions lib/src/cell/cell/double_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ extension DoubleConstCellExtensions on ConstCell<double> {
}

extension DoubleCellExtensions on Cell<double> {

/// Add
void add(double val) {
_val = _val + val;
Expand All @@ -79,13 +78,11 @@ extension DoubleCellExtensions on Cell<double> {
_val = _val - val;
}


/// multiply
void mul(double val) {
_val = _val * val;
}


/// divide
void div(double val) {
_val = _val / val;
Expand All @@ -96,7 +93,6 @@ extension DoubleCellExtensions on Cell<double> {
_val = _val % val;
}


/// Negate
void neg() {
_val = -_val;
Expand Down
3 changes: 0 additions & 3 deletions lib/src/cell/cell/int_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ extension IntConstCellExtensions on ConstCell<int> {
}

extension IntCellExtensions on Cell<int> {

/// Add
void add(int val) {
_val = _val + val;
Expand All @@ -85,7 +84,6 @@ extension IntCellExtensions on Cell<int> {
_val = _val * val;
}


/// Performs integer division of this object. Truncate Divide
void truncDiv(int val) {
_val = _val ~/ val;
Expand All @@ -96,7 +94,6 @@ extension IntCellExtensions on Cell<int> {
_val = _val % val;
}


/// Negate
void neg() {
_val = -_val;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cell/cell/string_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ extension StringCellExtensions on Cell<String> {
void add(String val) {
_val = _val + val;
}
}
}
9 changes: 5 additions & 4 deletions lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ConstNonNullableLazyCell<T extends Object> implements LazyCell<T> {
}

@override
bool isEvaluated(){
return (_cache[this] as T?) == null ? false : true;
bool isEvaluated() {
return (_cache[this] as T?) == null ? false : true;
}

@override
Expand All @@ -38,8 +38,9 @@ class ConstNonNullableLazyCell<T extends Object> implements LazyCell<T> {

@override
bool operator ==(Object other) {
return other is NullableLazyCell && ((isEvaluated() && other
.isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated()));
return other is NullableLazyCell &&
((isEvaluated() && other.isEvaluated() && this() == other()) ||
(!isEvaluated() && !other.isEvaluated()));
}

@override
Expand Down
9 changes: 5 additions & 4 deletions lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ConstNullableLazyCell<T> implements NullableLazyCell<T> {
}

@override
bool isEvaluated(){
return (_cache[this] as (T,)?) == null ? false : true;
bool isEvaluated() {
return (_cache[this] as (T,)?) == null ? false : true;
}

@override
Expand All @@ -37,8 +37,9 @@ class ConstNullableLazyCell<T> implements NullableLazyCell<T> {

@override
bool operator ==(Object other) {
return other is NullableLazyCell && ((isEvaluated() && other
.isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated()));
return other is NullableLazyCell &&
((isEvaluated() && other.isEvaluated() && this() == other()) ||
(!isEvaluated() && !other.isEvaluated()));
}

@override
Expand Down
11 changes: 7 additions & 4 deletions lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NonNullableLazyCell<T extends Object> implements LazyCell<T> {
}

@override
bool isEvaluated(){
bool isEvaluated() {
return _val == null ? false : true;
}

Expand All @@ -33,12 +33,15 @@ class NonNullableLazyCell<T extends Object> implements LazyCell<T> {

@override
bool operator ==(Object other) {
return other is NullableLazyCell && ((isEvaluated() && other
.isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated()));
return other is NullableLazyCell &&
((isEvaluated() && other.isEvaluated() && this() == other()) ||
(!isEvaluated() && !other.isEvaluated()));
}

@override
String toString() {
return (_val == null ? "Uninitialized $runtimeType" : "Initialized $runtimeType($_val)");
return (_val == null
? "Uninitialized $runtimeType"
: "Initialized $runtimeType($_val)");
}
}
14 changes: 9 additions & 5 deletions lib/src/cell/lazy_cell/nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class NullableLazyCell<T> {

NullableLazyCell(this._func);

const factory NullableLazyCell.constant(T Function() func, Object id) = ConstNullableLazyCell;
const factory NullableLazyCell.constant(T Function() func, Object id) =
ConstNullableLazyCell;

/// Lazily evaluates the function passed into the constructor.
T call() {
Expand All @@ -25,7 +26,7 @@ class NullableLazyCell<T> {
}

/// Returns true if this has already been called, otherwise false.
bool isEvaluated(){
bool isEvaluated() {
return _isSet;
}

Expand All @@ -37,12 +38,15 @@ class NullableLazyCell<T> {

@override
bool operator ==(Object other) {
return other is NullableLazyCell && ((isEvaluated() && other
.isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated()));
return other is NullableLazyCell &&
((isEvaluated() && other.isEvaluated() && this() == other()) ||
(!isEvaluated() && !other.isEvaluated()));
}

@override
String toString() {
return (_isSet ? "Initialized $runtimeType($_val)" : "Uninitialized $runtimeType");
return (_isSet
? "Initialized $runtimeType($_val)"
: "Uninitialized $runtimeType");
}
}
7 changes: 4 additions & 3 deletions lib/src/cell/once_cell/const_non_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ConstNonNullableOnceCell<T extends Object> implements OnceCell<T> {
}

@override
bool isSet(){
bool isSet() {
return (_cache[this] as T?) == null ? false : true;
}

Expand All @@ -105,8 +105,9 @@ class ConstNonNullableOnceCell<T extends Object> implements OnceCell<T> {

@override
bool operator ==(Object other) {
return other is NullableOnceCell && ((isSet() && other
.isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet()));
return other is NullableOnceCell &&
((isSet() && other.isSet() && getOrNull() == other.getOrNull()) ||
(!isSet() && !other.isSet()));
}

@override
Expand Down
7 changes: 4 additions & 3 deletions lib/src/cell/once_cell/const_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ConstNullableOnceCell<T> implements NullableOnceCell<T> {
}

@override
bool isSet(){
bool isSet() {
return (_cache[this] as (T,)?) == null ? false : true;
}

Expand All @@ -84,8 +84,9 @@ class ConstNullableOnceCell<T> implements NullableOnceCell<T> {

@override
bool operator ==(Object other) {
return other is NullableOnceCell && ((isSet() && other
.isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet()));
return other is NullableOnceCell &&
((isSet() && other.isSet() && getOrNull() == other.getOrNull()) ||
(!isSet() && !other.isSet()));
}

@override
Expand Down
11 changes: 7 additions & 4 deletions lib/src/cell/once_cell/non_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class NonNullableOnceCell<T extends Object> implements OnceCell<T> {
}

@override
bool isSet(){
bool isSet() {
return _val == null ? false : true;
}

Expand All @@ -95,12 +95,15 @@ class NonNullableOnceCell<T extends Object> implements OnceCell<T> {

@override
bool operator ==(Object other) {
return other is NullableOnceCell && ((isSet() && other
.isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet()));
return other is NullableOnceCell &&
((isSet() && other.isSet() && getOrNull() == other.getOrNull()) ||
(!isSet() && !other.isSet()));
}

@override
String toString() {
return (_val == null ? "Uninitialized $runtimeType" : "Initialized $runtimeType($_val)");
return (_val == null
? "Uninitialized $runtimeType"
: "Initialized $runtimeType($_val)");
}
}
11 changes: 7 additions & 4 deletions lib/src/cell/once_cell/nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class NullableOnceCell<T> {
}

/// Returns true if the value has been set. Returns false otherwise.
bool isSet(){
bool isSet() {
return _isSet;
}

Expand All @@ -80,12 +80,15 @@ class NullableOnceCell<T> {

@override
bool operator ==(Object other) {
return other is NullableOnceCell && ((isSet() && other
.isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet()));
return other is NullableOnceCell &&
((isSet() && other.isSet() && getOrNull() == other.getOrNull()) ||
(!isSet() && !other.isSet()));
}

@override
String toString() {
return (_isSet ? "Initialized $runtimeType($_val)" : "Uninitialized $runtimeType");
return (_isSet
? "Initialized $runtimeType($_val)"
: "Uninitialized $runtimeType");
}
}
2 changes: 1 addition & 1 deletion test/cell/cell_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void main() {
});
});

test('const cell', (){
test('const cell', () {
const constCell = ConstCell(1);
var cell = Cell(1);
expect(constCell, equals(cell));
Expand Down
12 changes: 6 additions & 6 deletions test/cell/lazy_call_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void main() {
});
});

test("LazyCell",(){
test("LazyCell", () {
int callCount = 0;
final lazyCell = LazyCell<int>(() {
callCount++;
Expand All @@ -195,11 +195,12 @@ void main() {
expect(secondCall, equals(20));
});

test("LazyCell Equality",(){
test("LazyCell Equality", () {
final nullableLazyCell = NullableLazyCell<int>(() {
return 20;
});
const constNonNullableLazyCell = ConstNonNullableLazyCell<int>(_constReturn20, "dfasdfas");
const constNonNullableLazyCell =
ConstNonNullableLazyCell<int>(_constReturn20, "dfasdfas");
expect(nullableLazyCell, equals(constNonNullableLazyCell));
nullableLazyCell();
expect(nullableLazyCell, isNot(equals(constNonNullableLazyCell)));
Expand All @@ -208,7 +209,6 @@ void main() {
});
}


int _constReturn20(){
int _constReturn20() {
return 20;
}
}
4 changes: 2 additions & 2 deletions test/cell/once_cell_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,15 @@ void main() {
expect(cell.hashCode, equals(cell2.hashCode));
});

test("OnceCell",(){
test("OnceCell", () {
final cell = OnceCell<int>();
var result = cell.set(10);
expect(result, const Ok(()));
result = cell.set(20);
expect(result, const Err(20));
});

test("OnceCell Equality",(){
test("OnceCell Equality", () {
final cell = OnceCell<int>();
const constNullableOnceCell = ConstNullableOnceCell<int>("agsagddg");
expect(cell, equals(constNullableOnceCell));
Expand Down

0 comments on commit 9a4dc4e

Please sign in to comment.