https://github.com/ngsankha/rbsyn Skip to content Sign up * Product + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} ngsankha / rbsyn Public * Notifications * Fork 2 * Star 44 Program synthesis for Ruby BSD-3-Clause License 44 stars 2 forks Star Notifications * Code * Issues 16 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 2 tags Code Latest commit @ngsankha ngsankha add output ... b66fe1e Apr 13, 2022 add output b66fe1e Git stats * 204 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows fix ruby versions Oct 1, 2021 bin code stats gathering tool Mar 1, 2021 components diaspora pod_schedule_check_if_needed May 3, 2020 docs timeout as env flag Mar 2, 2021 lib remove warnings Oct 1, 2021 models diaspora pod_schedule_check_if_needed May 3, 2020 scripts dataset equivalent to paper Mar 2, 2021 test rename pre to setup block Jun 9, 2020 .gitignore custom minitest reporter for benchmark stats Mar 14, 2020 Gemfile refine types after program is generated Jan 22, 2020 Gemfile.lock bump up gemfile lock Sep 30, 2021 LICENSE update readme and license Jul 2, 2021 README.md add output Apr 13, 2022 Rakefile faster smallbench suite Oct 1, 2021 rbsyn-logo.png rbsyn logo Jun 10, 2020 rbsyn.gemspec Update rake requirement from ~> 10.0 to ~> 13.0 Mar 1, 2021 View code RbSyn Installation Running Tests Environment Variables Using RbSyn Issues, questions or comments? README.md [rbsyn-logo] RbSyn RbSyn Build Status Program synthesis for Ruby, guided by type and effect annotations. See the PLDI 2021 paper for more details on the approach. Given a method specification in the form of tests, type and effect annotations with RDL, this synthesizes a Ruby function that will pass the tests. This reduces programmer effort to just writing tests that specify the function behavior and the computer writing the function implementation for you. Installation You need a working Ruby installation with Bundler installed. Then install all the dependencies by executing bundle install. We have tested RbSyn on Ruby 2.6.3 and 3.0.2 with Bundler 2.1.4. Other versions should work, but we have not tested it. Let us know if there are any issues. Running Tests All the benchmark programs can be run using the following command: bundle exec rake bench Prefix the environment variable CONSOLE_LOG=1 to the above command to print the synthesized method. To run a single test use the following command: bundle exec rake bench TEST= All the benchmarks can be found in test/benchmark and custom benchmarks can be run by updating in Rakefile in line 15, for the t.test_files value. Environment Variables Multiple flags can be passed to RbSyn to explore different configurations of synthesis: * CONSOLE_LOG=1: Print the programs that are bring synthesized. * DISABLE_TYPES=1: Disable type directed synthesis. * DISABLE_EFFECTS=1: Disable effect guided synthesis. * EFFECT_PREC=0 or EFFECT_PREC=1 or EFFECT_PREC=2: Set the level of effect precision to use. 0 is the most precise, 1 is class level precision and 2 reduces annotations to pure or impure only. These environment variables can be passed in any combination in the bench command like so: CONSOLE_LOG=1 DISABLE_EFFECTS=1 bundle exec rake bench Using RbSyn You can try to play with the implementation of RbSyn, the purpose of some of the key modules are given in the file structure section above. To write a new test, you can either copy an example from the existing benchmark and modify it. Update the Rakefile so the t.test_files contain your new benchmark. Benchmarks follow roughly this format: # type definitions for methods that will be used for synthesis RDL.type Array, :first, '() -> t', wrap: false define :username_available?, "(String) -> %bool" do spec "returns true when user doesn't exist" do username_available? 'bruce1' post { |result| result == true } end spec "returns false when user exists" do setup { u = User.create(name: 'Bruce Wayne', username: 'bruce1', password: 'coolcool') u.emails.create(email: 'bruce1@wayne.com') } username_available? 'bruce1' post { |result| result == false } end puts generate_program end The above generate_program runs RbSyn and produces the following snippet: def username_available?(arg0) !User.exists?(username: arg0) end By default RbSyn will only use "" (empty string), 0 and 1 for constants during synthesis. To include some other constants in this set, add them to lib/rbsyn/context.rb lines 26 and 27. nil is not synthesized by default, to enable the synthesis of nil set the option enable_nil: true. For an example see, test/benchmark/ diaspora/user_confirm_email_benchmark.rb. Issues, questions or comments? Please file an issue on Github if you have problem running RbSyn. Feel free to send an email to sankha@cs.umd.edu. --------------------------------------------------------------------- Logo derived from icon by ultimatearm from www.flaticon.com. About Program synthesis for Ruby Topics ruby rails program-synthesis ruby-on-rails Resources Readme License BSD-3-Clause License Stars 44 stars Watchers 4 watching Forks 2 forks Releases 2 tags Contributors 2 * @ngsankha ngsankha Sankha Narayan Guria * @dependabot[bot] dependabot[bot] Languages * Ruby 90.6% * Python 9.3% * Shell 0.1% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.