File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/lib/ruby-to-blocks-converter
test/unit/lib/ruby-to-blocks-converter Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ class RubyToBlocksConverter {
7777 try {
7878 const root = RubyParser . $parse ( code ) ;
7979 let blocks = this . _process ( root ) ;
80+ if ( blocks === null || blocks === Opal . nil ) {
81+ return true ;
82+ }
8083 if ( ! _ . isArray ( blocks ) ) {
8184 blocks = [ blocks ] ;
8285 }
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ describe('RubyToBlocksConverter', () => {
2626 expect ( Object . keys ( converter . lists ) ) . toHaveLength ( 0 ) ;
2727 } ) ;
2828
29+ test ( 'empty' , ( ) => {
30+ expect ( converter . targetCodeToBlocks ( target , '' ) ) . toBeTruthy ( ) ;
31+ expect ( Object . keys ( converter . blocks ) ) . toHaveLength ( 0 ) ;
32+ expect ( converter . errors ) . toHaveLength ( 0 ) ;
33+ expect ( Object . keys ( converter . variables ) ) . toHaveLength ( 0 ) ;
34+ expect ( Object . keys ( converter . lists ) ) . toHaveLength ( 0 ) ;
35+ } ) ;
36+
37+
2938 describe ( 'top level blocks' , ( ) => {
3039 test ( 'statements' , ( ) => {
3140 expected = [
You can’t perform that action at this time.
0 commit comments