Tuesday, April 23, 2019

How to Build Runnable JavaScript Specifications

Programming is not only about giving the computer instructions about how to accomplish a task, it’s also about communicating ideas in a precise way with other people, or even to your future self. Such communication can have multiple goals, maybe to share information or just to allow easier modifications—it’s hard to change something if you don’t understand it or if you don’t remember what you did long time ago. Documentation is key, either as simple comments in your code or as whole documents describing the overall functionality of a program.

A Simple JavaScript Specification File

When we write software we also need to make sure that the code has the intended functionality. While there are formal methods to define semantics, the easiest and quickest (but less rigorous) way is to put that functionality into use and see if it produces the expected results.

Most developers are familiar with these practices: code documentation as comments to make explicit the goal of a block of code, and a series of tests to make sure functions give the desired output.

But usually the documentation and testing is done in different steps, and by unifying these practices, we can offer a better experience for anyone involved in the development of a project. This article explores as simple implementation of a program to run JavaScript specifications that work for both documentation and testing.

We are going to build a command-line interface that finds all the specification files in a directory, extracts all the assertions found inside each specification and evaluates their result, finally showing the results of which assertions failed and which ones passed.

The Specification Format

Each specification file will export a single string from a template literal. The first line can be taken as the title of the specification. The template literal will allow us to embed JS expressions between the string and each expression will represent an assertion. To identify each assertion we can start the line with a distinctive character, in this case, we can use the combination of the bar character (|) and a dash (-), which resembles a turnstile symbol that can sometimes be found as a symbolic representation for logical assertions.

The following is an example with some explanations of its use:

The post How to Build Runnable JavaScript Specifications appeared first on SitePoint.


by James Kolce via SitePoint

After nearly 2 years of absence, the new version of Vine has initiated Beta Testing!

The now-defunct Vine app has given us a lot of influential YouTube celebrities such as the Paul Brothers and David Dobrik. Around a year and a half ago, one of Vine’s co-founders, Dom Hoffman announced the return of Vine, with a new name (Byte). However, the lack of follow-up led us to believe that...

[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]

by Ali Siddiqui via Digital Information World

The Cost Of Counterfeits - And How To Avoid Them (infographic)

Counterfeit electronics are a huge problem. You can buy a counterfeit version of the latest smartphone for 90% less than what the real deal would cost you, and unless you know what you are looking for you almost wouldn’t know the difference. So what’s the big deal, anyway? Unfortunately...

[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

AV-TEST's Research Explains why you should Immediately Switch from Google Play Protect to another App for Securing your Android Device!

AV-TEST recently conducted a number of tests on several security apps for Android devices. The results were quite surprising, to say the least. In total, there were 19 apps that were properly analyzed. The test was conducted on basis of protection, usability and features. A total of 6 points were...

[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]

by Ali Siddiqui via Digital Information World

FullScreen Slider with Wheel/Touch Events

fullscreen-slider is an asset that resizes sections in a page to fullscreen resolution and moves these individually by wheel/touch events.


by via jQuery-Plugins.net RSS Feed

Google Lens to Introduce Various New Features Including Translate, Dining

Google Lens despite being smart still has certain limitations and thus refer you to other apps for the solution. According to a recent report by 9to5Google, specific augmented realities tasks will soon be fulfilled with the introduction of new filters in the Lens. This will lower the dependency on...

[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]

by Aqsa Rasool via Digital Information World

How to Use Google Data Studio to Analyze Your Facebook Ads

Want to better understand your Facebook ad performance? Have you considered using Google Data Studio? In this article, you’ll discover how to create seven valuable Google Data Studio charts that can help you better analyze your Facebook advertising campaigns. How to Create Charts in Google Data Studio Data Studio is a free tool created by […]

The post How to Use Google Data Studio to Analyze Your Facebook Ads appeared first on Social Media Marketing | Social Media Examiner.


by Karley Ice via Social Media Marketing | Social Media Examiner