This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Block + BlockBuilder, some utilities. (#134)
* Initial support for Expression(s). * More in changelog. * Add context everywhere. * All tests passing. * More cleanup. * More expression work. * Improve calls, add property access. * Update README. * Actually update it. * Be nice to users. * Add literalString, literalMap. * Add blocks of code (statements).
- Loading branch information
1 parent
1aacdfa
commit a9d0ce5
Showing
9 changed files
with
228 additions
and
8 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:code_builder/code_builder.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('should emit a block of code', () { | ||
expect( | ||
new Block((b) => b.statements.addAll([ | ||
const Code('if (foo) {'), | ||
const Code(' print(true);'), | ||
const Code('}'), | ||
])), | ||
equalsDart(r''' | ||
if (foo) { | ||
print(true); | ||
} | ||
'''), | ||
); | ||
}); | ||
|
||
test('should emit a block of code including expressions', () { | ||
expect( | ||
new Block((b) => b.statements.addAll([ | ||
const Code('if (foo) {'), | ||
refer('print')([literalTrue]).asStatement(), | ||
const Code('}'), | ||
])), | ||
equalsDart(r''' | ||
if (foo) { | ||
print(true); | ||
} | ||
'''), | ||
); | ||
}); | ||
} |